mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-20 11:48:31 -06:00
Improve s3 exceptions logging
This commit is contained in:
parent
3116309914
commit
bff5682f6c
@ -332,21 +332,25 @@ async function uploadToStorage (options: {
|
||||
params: input
|
||||
})
|
||||
|
||||
const response = await parallelUploads3.done()
|
||||
// Check is needed even if the HTTP status code is 200 OK
|
||||
// For more information, see https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html
|
||||
if (!response.Bucket) {
|
||||
const message = `Error uploading ${objectStorageKey} to bucket ${bucketInfo.BUCKET_NAME}`
|
||||
logger.error(message, { response, ...lTags() })
|
||||
throw new Error(message)
|
||||
try {
|
||||
const response = await parallelUploads3.done()
|
||||
// Check is needed even if the HTTP status code is 200 OK
|
||||
// For more information, see https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html
|
||||
if (!response.Bucket) {
|
||||
const message = `Error uploading ${objectStorageKey} to bucket ${bucketInfo.BUCKET_NAME}`
|
||||
logger.error(message, { response, ...lTags() })
|
||||
throw new Error(message)
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
'Completed %s%s in bucket %s',
|
||||
bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, { ...lTags(), responseMetadata: response.$metadata }
|
||||
)
|
||||
|
||||
return getInternalUrl(bucketInfo, objectStorageKey)
|
||||
} catch (err) {
|
||||
throw parseS3Error(err)
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
'Completed %s%s in bucket %s',
|
||||
bucketInfo.PREFIX, objectStorageKey, bucketInfo.BUCKET_NAME, { ...lTags(), reseponseMetadata: response.$metadata }
|
||||
)
|
||||
|
||||
return getInternalUrl(bucketInfo, objectStorageKey)
|
||||
}
|
||||
|
||||
async function applyOnPrefix (options: {
|
||||
@ -395,3 +399,19 @@ function getACL (isPrivate: boolean) {
|
||||
? CONFIG.OBJECT_STORAGE.UPLOAD_ACL.PRIVATE as ObjectCannedACL
|
||||
: CONFIG.OBJECT_STORAGE.UPLOAD_ACL.PUBLIC as ObjectCannedACL
|
||||
}
|
||||
|
||||
// Prevent logging too much information, in particular the body request
|
||||
function parseS3Error (err: any) {
|
||||
if (err.$response?.body) {
|
||||
const body = err.$response.body
|
||||
|
||||
err.$response.body = {
|
||||
rawHeaders: body.rawHeaders,
|
||||
req: {
|
||||
_header: body.req?._header
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ app.use((_req, res: express.Response) => {
|
||||
})
|
||||
|
||||
// Catch thrown errors
|
||||
app.use((err, _req, res: express.Response, _next) => {
|
||||
app.use((err, req, res: express.Response, _next) => {
|
||||
// Format error to be logged
|
||||
let error = 'Unknown error.'
|
||||
if (err) {
|
||||
@ -281,7 +281,7 @@ app.use((err, _req, res: express.Response, _next) => {
|
||||
? (process as any)._getActiveRequests()
|
||||
: undefined
|
||||
|
||||
logger.error('Error in controller.', { err: error, sql, activeRequests })
|
||||
logger.error('Error in controller.', { err: error, sql, activeRequests, url: req.originalUrl })
|
||||
|
||||
return res.fail({
|
||||
status: err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500,
|
||||
|
Loading…
Reference in New Issue
Block a user