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

Errors in Graphcache updaters are swallowed #2285

Closed
ianschmitz opened this issue Feb 16, 2022 · 1 comment · Fixed by #2287
Closed

Errors in Graphcache updaters are swallowed #2285

ianschmitz opened this issue Feb 16, 2022 · 1 comment · Fixed by #2287
Labels
bug 🐛 Oh no! A bug or unintented behaviour.

Comments

@ianschmitz
Copy link

I've noticed that errors originating from Graphcache updaters appear to get swallowed. This took me quite a while to figure out why my mutations were executing twice all of a sudden, and it was eventually discovered to be due to my cache.invalidate() logic that was throwing an error. I don't believe errors should be caught and swallowed like they are now as it makes debugging quite difficult, and prevents error tracing tools from being able to catch potential issues in production.

urql version & exchanges:
urql@2.1.3
graphcache@4.3.6

Steps to reproduce

  1. Create an updater that throws such as example below.
  2. Trigger mutation that would run the updater logic
  3. Observe console, etc. that the error isn't visible/obvious

Example:

createClient({
    exchanges: [
        dedupExchange,
        cacheExchange({
            updates: {
                Mutation: {
                    insertTodo(_result, args, cache, _info) {
                        throw new Error("You should see this somewhere");
                    }
                },
            },
        }),
        fetchExchange,
    ]
})

Expected behavior

I would expect a catastrophic error in an updater to be visible to the developer, ideally by throwing all the way up so that error tracing tools can catch and report on it. I spent quite a bit of time wondering why my mutation was causing two identical HTTP requests and realized that my updater was erroring out after careful debugging.

Actual behavior

Error in updater is swallowed, and the mutation runs twice instead of once, creating two todo items.

@ianschmitz ianschmitz added the bug 🐛 Oh no! A bug or unintented behaviour. label Feb 16, 2022
@JoviDeCroock
Copy link
Collaborator

JoviDeCroock commented Feb 18, 2022

This should be fixed in @urql/core 2.4.2 by the #2287 PR

EDIT: closing this feel free to reopen if you encounter this issue further

@JoviDeCroock JoviDeCroock linked a pull request Feb 18, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Oh no! A bug or unintented behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants