🐛 fix: Configure S3 client to bypass proxy for reliable uploads

Co-authored-by: GeorgeDong32 <98630204+GeorgeDong32@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-10-29 07:29:24 +00:00 committed by GeorgeDong32
parent 33983c26f4
commit 7a49042d7f

View File

@ -6,9 +6,11 @@ import {
PutObjectCommand,
S3Client
} from '@aws-sdk/client-s3'
import { FetchHttpHandler } from '@smithy/fetch-http-handler'
import { loggerService } from '@logger'
import type { S3Config } from '@types'
import * as net from 'net'
import { Agent as UndiciAgent } from 'undici'
import { Readable } from 'stream'
const logger = loggerService.withContext('S3Storage')
@ -57,6 +59,20 @@ export default class S3Storage {
}
})()
// Create a direct dispatcher for S3 to bypass proxy
// This prevents proxy interference with large file uploads that can cause incomplete transfers
const directDispatcher = new UndiciAgent({
connect: {
timeout: 60000 // 60 second connection timeout
}
})
// Use FetchHttpHandler with direct dispatcher to bypass global proxy settings
const requestHandler = new FetchHttpHandler({
requestTimeout: 300000, // 5 minute request timeout for large files
dispatcher: directDispatcher
})
this.client = new S3Client({
region,
endpoint: endpoint || undefined,
@ -64,7 +80,8 @@ export default class S3Storage {
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey
},
forcePathStyle: usePathStyle
forcePathStyle: usePathStyle,
requestHandler
})
this.bucket = bucket