Skip to content

Commit

Permalink
(core) - fix incremental fetch not bubbling up JS-errors (#2210)
Browse files Browse the repository at this point in the history
* fix incremental fetch not bubbling up JS-errors

* the stack exists

* Update fetchSource.ts

* formatting
  • Loading branch information
JoviDeCroock authored Jan 21, 2022
1 parent c4a0ede commit 20b7951
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-brooms-fix.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions packages/core/src/internal/fetchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 20b7951

Please sign in to comment.