diff --git a/.changeset/smart-brooms-fix.md b/.changeset/smart-brooms-fix.md new file mode 100644 index 0000000000..968f5a93e0 --- /dev/null +++ b/.changeset/smart-brooms-fix.md @@ -0,0 +1,5 @@ +--- +'@urql/core': patch +--- + +Fix error bubbling, when an error happened in the exchange-pipeline we would treat it as a GraphQL-error diff --git a/packages/core/src/internal/fetchSource.ts b/packages/core/src/internal/fetchSource.ts index e5e8b3b9fb..fa4a62f456 100644 --- a/packages/core/src/internal/fetchSource.ts +++ b/packages/core/src/internal/fetchSource.ts @@ -146,6 +146,14 @@ export const makeFetchSource = ( }) .then(complete) .catch((error: Error) => { + if (error.name === 'SyntaxError' || error.name === 'TypeError') { + const e = new Error(error.message); + e.stack = + e.stack!.split('\n').slice(0, 2).join('\n') + '\n' + error.stack; + e.constructor = error.constructor; + throw e; + } + if (error.name !== 'AbortError') { const result = makeErrorResult( operation,