From 30e7afda475cc3b7783f1eb23b148014731868e7 Mon Sep 17 00:00:00 2001 From: Seth Holladay Date: Mon, 9 Dec 2024 18:52:04 -0500 Subject: [PATCH] Fix memory leak from cloned responses (#661) 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. --- source/core/Ky.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/core/Ky.ts b/source/core/Ky.ts index d69c03ef..0bde49b3 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -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) {