Skip to content

Commit 95aa6c0

Browse files
committed
refactor: import nodehttp handler directly
1 parent c33267d commit 95aa6c0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/core/src/shared/awsClientBuilderV3.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { partialClone } from './utilities/collectionUtils'
3636
import { selectFrom } from './utilities/tsUtils'
3737
import { once } from './utilities/functionUtils'
3838
import { isWeb } from './extensionGlobals'
39+
import { NodeHttpHandler } from '@smithy/node-http-handler'
3940

4041
export type AwsClientConstructor<C> = new (o: AwsClientOptions) => C
4142

@@ -92,12 +93,10 @@ export class AWSClientBuilderV3 {
9293
}
9394

9495
private buildHttpClient() {
95-
// Workaround for web mode to avoid importing @smithy/node-http-handler unless in node.
96-
if (!isWeb()) {
97-
const { NodeHttpHandler } = require('@smithy/node-http-handler')
98-
return new NodeHttpHandler({ keepAlive: true })
99-
}
100-
return new FetchHttpHandler({ keepAlive: true })
96+
const requestTimeout = 30000
97+
return isWeb()
98+
? new FetchHttpHandler({ keepAlive: true, requestTimeout })
99+
: new NodeHttpHandler({ httpAgent: { keepAlive: true }, httpsAgent: { keepAlive: true }, requestTimeout })
101100
}
102101

103102
private getHttpClient = once(this.buildHttpClient.bind(this))

0 commit comments

Comments
 (0)