Open adrian-skybaker opened 6 months ago
Hey @adrian-skybaker 👋
Thanks for opening this request! I think it makes sense for us to add support for Error.cause
here which I would imagine would help here quite a bit. This is something we've talked about internally a couple times, but this is good signal that we should look at this perhaps sooner than later.
This would be very helpful, I was also confused why Sentry doesn't show correct stack traces for GQL errors.
Same issue here, hard to trace issues at the Sentry.captureExpception
if its called once at the onError
apolloLink level. Would be useful to see where the original call and its context came from in the stack
When handling errors in https://www.apollographql.com/docs/react/api/link/apollo-link-error/, there is no ability to determine the stack trace of the error that includes the original trigger for the query.
This is problematic both when logging errors locally, and reporting helpful errors to tools like Sentry.io, which accept Error objects and present stack traces helpfully.
Raising a new Error object from within an onError handler doesn't work, presumably because of the callback nature of the handler.
The only workaround I've found is to implement a separate link that populates the stack into the context:
This is not ideal as it wastefully records the stack for every request, even if no error occurs.
This gap has been raised several times, but I don't believe it's currently captured as a feature request here: