Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(core) - fix incremental fetch not bubbling up JS-errors #2210

Merged
merged 4 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a bit too limiting 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we limit this to development?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well my thinking was that people using for instance Sentry in production would want to see these errors surface as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yea good point

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