From e824520bf6a0c66d3b304c2990e38a0b0015cbcb Mon Sep 17 00:00:00 2001
From: Travis Briggs <audiodude@gmail.com>
Date: Wed, 30 Oct 2024 19:43:47 -0700
Subject: [PATCH] Increase S3 socket limit to 250

---
 src/S3.ts | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/S3.ts b/src/S3.ts
index 1c1d8002..c5271906 100644
--- a/src/S3.ts
+++ b/src/S3.ts
@@ -3,6 +3,9 @@ import * as logger from './Logger.js'
 import { Readable } from 'stream'
 import { publicIpv4 } from 'public-ip'
 
+import * as https from 'https'
+import { NodeHttpHandler } from '@smithy/node-http-handler'
+
 interface BucketParams {
   Bucket: string
   Key: string
@@ -34,6 +37,11 @@ class S3 {
   }
 
   public async initialise() {
+    const requestHandler = new NodeHttpHandler({
+      httpsAgent: new https.Agent({
+        maxSockets: 250,
+      }),
+    })
     const s3UrlBase: any = new URL(this.url)
     this.s3Handler = new S3Client({
       credentials: {
@@ -43,6 +51,7 @@ class S3 {
       endpoint: s3UrlBase.href,
       forcePathStyle: s3UrlBase.protocol === 'http:',
       region: this.region,
+      requestHandler,
     })
 
     return this.bucketExists(this.bucketName)