fix: increase s3 client max socket limit (#2355)

This commit is contained in:
Philip Okugbe
2026-07-21 22:59:25 +01:00
committed by GitHub
parent 0ba2d78660
commit 70d2ff8685
@@ -15,13 +15,21 @@ import { getMimeType } from '../../../common/helpers';
import { Upload } from '@aws-sdk/lib-storage'; import { Upload } from '@aws-sdk/lib-storage';
import { Logger } from '@nestjs/common'; import { Logger } from '@nestjs/common';
const S3_MAX_SOCKETS = 200;
export class S3Driver implements StorageDriver { export class S3Driver implements StorageDriver {
private readonly s3Client: S3Client; private readonly s3Client: S3Client;
private readonly config: S3StorageConfig; private readonly config: S3StorageConfig;
constructor(config: S3StorageConfig) { constructor(config: S3StorageConfig) {
this.config = config; this.config = {
this.s3Client = new S3Client(config as any); ...config,
requestHandler: {
httpAgent: { maxSockets: S3_MAX_SOCKETS },
httpsAgent: { maxSockets: S3_MAX_SOCKETS },
},
};
this.s3Client = new S3Client(this.config as any);
} }
async upload(filePath: string, file: Buffer | Readable): Promise<void> { async upload(filePath: string, file: Buffer | Readable): Promise<void> {