Skip to content

Commit

Permalink
fix(server): give s3 client a default request timeout (toeverything#6483
Browse files Browse the repository at this point in the history
)
  • Loading branch information
forehalo committed Apr 8, 2024
1 parent 9f66b81 commit b01a8bb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/backend/server/src/plugins/storage/providers/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}

Expand Down

0 comments on commit b01a8bb

Please sign in to comment.