Skip to content

Commit c5be841

Browse files
authored
Fetch with an uncloned request when possible (#601)
1 parent 974f1e9 commit c5be841

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/core/Ky.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,15 @@ export class Ky {
300300

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

303+
// Cloning is done here to prepare in advance for retries
304+
const mainRequest = this.request;
305+
this.request = mainRequest.clone();
306+
303307
if (this._options.timeout === false) {
304-
return this._options.fetch(this.request.clone(), nonRequestOptions);
308+
return this._options.fetch(mainRequest, nonRequestOptions);
305309
}
306310

307-
return timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options as TimeoutOptions);
311+
return timeout(mainRequest, nonRequestOptions, this.abortController, this._options as TimeoutOptions);
308312
}
309313

310314
/* istanbul ignore next */

0 commit comments

Comments
 (0)