-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Discussion/feature request: custom error handling #1141
Comments
@dallonf The reason we solved it the way we did for now is that we can't call the error callback because that's what threw the error in the first place, and we can't just throw the error, because if we did none of the other queries would get updated in @calebmer what are your thoughts here on how best to deal with those errors? |
It looks like the I think the correct thing to do here is to make sure errors like these make their way out of Apollo as unhandled exceptions. By logging them to the console with I’ve read up on some of the issues/PRs that ended up adding the setImmediate(() => observer.next(value))
// ...or for better runtime support
setTimeout(() => observer.next(value), 0) The When looking at the issues/PRs that added the |
That doesn't sound like a super hard PR for me. Let me know if that's the right approach and I can cook something up in a couple days! |
@calebmer Great idea! I think |
Well... I thought it would be pretty easy. But the unit tests for this are something else, lol. Could use some help on this. |
Any progress on this? |
@fischerman or @dallonf if you’d like to open a PR with this change we would be happy with helping you fix the unit tests 👍 |
OK, created the PR! |
For my current project, we use
apollo-react
and Sentry (for error reporting and tracking).Now, errors in render functions are historically something that React doesn't handle very elegantly, but usually they at least bubble up as an uncaught exception or unhandled promise rejection, and Sentry can detect this and report them.
However, when a render error happens in response to an update from Apollo, the error gets logged by
console.error
, here: https://github.com/apollostack/apollo-client/blob/v0.5.25/src/core/QueryManager.ts#L375In order to report these errors to Sentry, I actually have to monkeypatch
console.error
, which I'm not really pleased with as a solution.I don't know what a better solution would be - probably raising them as an uncaught exception. Or if this is happening in promise-land, I'd also be fine with a promise rejection, as we're using core-js promises and those do a pretty good job of reporting unhandled rejections, but I suspect that's not the case for everyone. Maybe the Apollo client should be configurable as to where these errors go?
The text was updated successfully, but these errors were encountered: