Skip to content

Commit

Permalink
Fix memory leak from cloned responses (#661)
Browse files Browse the repository at this point in the history
Fixes #648

This removes an unnecessary response clone that was used in body method shortcuts, such as `ky().json()`, which caused the original response to be fully buffered and never consumed.
  • Loading branch information
sholladay authored Dec 9, 2024
1 parent 3ba40cc commit 30e7afd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions source/core/Ky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export class Ky {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);

const awaitedResult = await result;
const response = awaitedResult.clone();
const response = await result;

if (type === 'json') {
if (response.status === 204) {
Expand Down

0 comments on commit 30e7afd

Please sign in to comment.