Skip to content

Commit

Permalink
Fetch with an uncloned request when possible (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
sholladay authored Jun 26, 2024
1 parent 974f1e9 commit c5be841
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/core/Ky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,15 @@ export class Ky {

const nonRequestOptions = findUnknownOptions(this.request, this._options);

// Cloning is done here to prepare in advance for retries
const mainRequest = this.request;
this.request = mainRequest.clone();

if (this._options.timeout === false) {
return this._options.fetch(this.request.clone(), nonRequestOptions);
return this._options.fetch(mainRequest, nonRequestOptions);
}

return timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options as TimeoutOptions);
return timeout(mainRequest, nonRequestOptions, this.abortController, this._options as TimeoutOptions);
}

/* istanbul ignore next */
Expand Down

0 comments on commit c5be841

Please sign in to comment.