Skip to content

Commit

Permalink
fix: default keepalive=false for fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Oct 10, 2023
1 parent 5fb6d4c commit d86c798
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-scissors-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/fetch-http-handler": patch
---

set keepalive default to false in fetch handler
10 changes: 8 additions & 2 deletions packages/fetch-http-handler/src/fetch-http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ export interface FetchHttpHandlerOptions {
requestTimeout?: number;

/**
* Whether to allow the request to outlive the page. Default value is true
* Whether to allow the request to outlive the page. Default value is false.
*
* There may be limitations to the payload size, number of concurrent requests,
* request duration etc. when using keepalive in browsers.
*
* These may change over time, so look for up to date information about
* these limitations before enabling keepalive.
*/
keepAlive?: boolean;
}
Expand Down Expand Up @@ -59,7 +65,7 @@ export class FetchHttpHandler implements HttpHandler<FetchHttpHandlerConfig> {
this.config = await this.configProvider;
}
const requestTimeoutInMs = this.config!.requestTimeout;
const keepAlive = this.config!.keepAlive ?? true;
const keepAlive = this.config!.keepAlive === true;

// if the request was already aborted, prevent doing extra work
if (abortSignal?.aborted) {
Expand Down

0 comments on commit d86c798

Please sign in to comment.