Skip to content

Commit 339eb59

Browse files
committed
deps: import conditionally to allow web to work
1 parent 4afaf38 commit 339eb59

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@
522522
"@smithy/shared-ini-file-loader": "^3.0.0",
523523
"@smithy/util-retry": "^3.0.0",
524524
"@smithy/fetch-http-handler": "^3.0.0",
525+
"@smithy/node-http-handler": "^3.0.0",
525526
"@vscode/debugprotocol": "^1.57.0",
526527
"@zip.js/zip.js": "^2.7.41",
527528
"adm-zip": "^0.5.10",

packages/core/src/shared/awsClientBuilderV3.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { getLogger } from './logger/logger'
3535
import { partialClone } from './utilities/collectionUtils'
3636
import { selectFrom } from './utilities/tsUtils'
3737
import { once } from './utilities/functionUtils'
38+
import { isWeb } from './extensionGlobals'
3839

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

@@ -91,9 +92,12 @@ export class AWSClientBuilderV3 {
9192
}
9293

9394
private buildHttpClient() {
94-
return new FetchHttpHandler({
95-
keepAlive: true,
96-
})
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 })
97101
}
98102

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

0 commit comments

Comments
 (0)