From b01a8bb2abda28fa81618cdcbad76e2861927a04 Mon Sep 17 00:00:00 2001 From: forehalo Date: Mon, 8 Apr 2024 08:41:55 +0000 Subject: [PATCH] fix(server): give s3 client a default request timeout (#6483) --- .../backend/server/src/plugins/storage/providers/s3.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/backend/server/src/plugins/storage/providers/s3.ts b/packages/backend/server/src/plugins/storage/providers/s3.ts index d665dfa37425f..cb0bc2a2b005e 100644 --- a/packages/backend/server/src/plugins/storage/providers/s3.ts +++ b/packages/backend/server/src/plugins/storage/providers/s3.ts @@ -32,7 +32,14 @@ export class S3StorageProvider implements StorageProvider { config: S3StorageConfig, public readonly bucket: string ) { - this.client = new S3Client({ region: 'auto', ...config }); + this.client = new S3Client({ + region: 'auto', + // s3 client uses keep-alive by default to accelrate requests, and max requests queue is 50. + // If some of them are long holding or dead without response, the whole queue will block. + // By default no timeout is set for requests or connections, so we set them here. + requestHandler: { requestTimeout: 60_000, connectionTimeout: 10_000 }, + ...config, + }); this.logger = new Logger(`${S3StorageProvider.name}:${bucket}`); }