Skip to content

Commit

Permalink
Throw JSON error if initial JSON is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Mar 14, 2023
1 parent 6903339 commit bc8b587
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/internal/fetchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit bc8b587

Please sign in to comment.