From a1ddb494095586a0ec6fbb9ecfb784fa1d1f75b4 Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Tue, 14 Mar 2023 17:07:19 +0000 Subject: [PATCH] Remove hasResults check --- packages/core/src/internal/fetchSource.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/core/src/internal/fetchSource.ts b/packages/core/src/internal/fetchSource.ts index ef86e354cf..fd2076e344 100644 --- a/packages/core/src/internal/fetchSource.ts +++ b/packages/core/src/internal/fetchSource.ts @@ -34,8 +34,8 @@ async function* fetchOperation( fetchOptions: RequestInit ) { let abortController: AbortController | void; + let result: OperationResult | null = null; let response: Response; - let hasResults = false; try { if (typeof AbortController !== 'undefined') { @@ -62,9 +62,7 @@ async function* fetchOperation( let buffer = ''; let isPreamble = true; - let result: OperationResult | null = null; chunks: for await (const data of iterator) { - hasResults = true; buffer += toString(data); let boundaryIndex: number; @@ -89,7 +87,8 @@ async function* fetchOperation( } catch (_error) {} if (next.startsWith('--') || (payload && !payload.hasNext)) { - if (!result) yield makeResult(operation, {}, response); + if (!result) + yield (result = makeResult(operation, {}, response)); break chunks; } } @@ -98,7 +97,7 @@ async function* fetchOperation( } } } catch (error: any) { - if (hasResults) { + if (result) { throw error; }