Skip to content

Commit

Permalink
fix(fetch-http-handler): move keepalive check to constructor (one-time)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Jun 17, 2024
1 parent aec00b0 commit aa6e308
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/fetch-http-handler/src/fetch-http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type FetchHttpHandlerConfig = FetchHttpHandlerOptions;
* Detection of keepalive support. Can be overridden for testing.
*/
export const keepAliveSupport = {
supported: Boolean(typeof Request !== "undefined" && "keepalive" in new Request("https://[::1]")),
supported: undefined,
};

/**
Expand Down Expand Up @@ -60,6 +60,11 @@ export class FetchHttpHandler implements HttpHandler<FetchHttpHandlerConfig> {
this.config = options ?? {};
this.configProvider = Promise.resolve(this.config);
}
if (keepAliveSupport.supported === undefined) {
keepAliveSupport.supported = Boolean(
typeof Request !== "undefined" && "keepalive" in new Request("https://[::1]")
);
}
}

destroy(): void {
Expand Down

0 comments on commit aa6e308

Please sign in to comment.