Skip to content

Commit fedce37

Browse files
authored
fix(fetch-http-handler): move keepalive check to constructor (one-time) (#1310)
1 parent dddbe3c commit fedce37

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/eighty-impalas-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/fetch-http-handler": patch
3+
---
4+
5+
move keepAliveSupport check to FetchHttpHandler constructor

packages/fetch-http-handler/src/fetch-http-handler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type FetchHttpHandlerConfig = FetchHttpHandlerOptions;
1616
* Detection of keepalive support. Can be overridden for testing.
1717
*/
1818
export const keepAliveSupport = {
19-
supported: Boolean(typeof Request !== "undefined" && "keepalive" in new Request("https://[::1]")),
19+
supported: undefined as undefined | boolean,
2020
};
2121

2222
/**
@@ -60,6 +60,11 @@ export class FetchHttpHandler implements HttpHandler<FetchHttpHandlerConfig> {
6060
this.config = options ?? {};
6161
this.configProvider = Promise.resolve(this.config);
6262
}
63+
if (keepAliveSupport.supported === undefined) {
64+
keepAliveSupport.supported = Boolean(
65+
typeof Request !== "undefined" && "keepalive" in new Request("https://[::1]")
66+
);
67+
}
6368
}
6469

6570
destroy(): void {

0 commit comments

Comments
 (0)