From fc0bab8f41c25204fcc5124a1420934002eae51e Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Sep 2021 09:24:39 +0200 Subject: [PATCH] fix: handle error while sending content from s3 --- src/storage/S3.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/storage/S3.ts b/src/storage/S3.ts index 7258ddf..e471b75 100644 --- a/src/storage/S3.ts +++ b/src/storage/S3.ts @@ -88,6 +88,13 @@ export default class S3Storage implements StorageBase { Bucket: config.S3_BUCKET, Key: p, }) + .on("error", (error) => { + try { + res.status(error.statusCode); + } catch (err) { + console.error(err); + } + }) .on("httpHeaders", (statusCode, headers, response) => { res.status(statusCode); if (statusCode < 300) {