From eedc5404a9a94e8db8c7916beb58dd2026e42b0e Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Tue, 14 Mar 2023 18:45:56 +0000 Subject: [PATCH] Add missing reader.cancel call --- packages/core/src/internal/fetchSource.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/internal/fetchSource.ts b/packages/core/src/internal/fetchSource.ts index b97d943229..40e6eb5574 100644 --- a/packages/core/src/internal/fetchSource.ts +++ b/packages/core/src/internal/fetchSource.ts @@ -21,7 +21,11 @@ async function* streamBody(response: Response): AsyncIterableIterator { } else { const reader = response.body!.getReader(); let result: ReadableStreamReadResult; - while (!(result = await reader.read()).done) yield toString(result.value); + try { + while (!(result = await reader.read()).done) yield toString(result.value); + } finally { + reader.cancel(); + } } }