From bc8b58702fcb3c7e5314f977bb7652af9314a843 Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Tue, 14 Mar 2023 18:35:41 +0000 Subject: [PATCH] Throw JSON error if initial JSON is invalid --- packages/core/src/internal/fetchSource.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/internal/fetchSource.ts b/packages/core/src/internal/fetchSource.ts index 5beb211c8b..b97d943229 100644 --- a/packages/core/src/internal/fetchSource.ts +++ b/packages/core/src/internal/fetchSource.ts @@ -47,9 +47,12 @@ async function* parseMultipartChunks( buffer.indexOf('\r\n\r\n') + 4, boundaryIndex ); + try { yield (payload = JSON.parse(chunk)); - } catch (_error) {} + } catch (error) { + if (!payload) throw error; + } buffer = buffer.slice(boundaryIndex + boundary.length); if (buffer.startsWith('--') || (payload && !payload.hasNext))