-
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
Error handling for unmounted component #2258
Comments
@Jay1337 interesting! Do you have a reproduction for this? I think it should be fixed in the 2.0 though since the new interface is an observable which will correctly clean up errors |
@jbaxleyiii I'm only working with 2.0 beta and it's not fixed... Sorry I don't have (time to make) a simple reproduction (it would require server and client code). However, it could be an app with a toggle button that display a React component when you press it. The React component is wrapped with a wrong graphql query. The server wait 10s before sending the response. Thus, if you press the button and then immediately "unpress" the button (so that the component is unmounted), after 10s you will get a |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client! |
Hey ! |
I'm also seeing unhandled ApolloError when component is unmounted. I'm using
In particular, |
I made a reproduction with the error template |
|
This issue is still present in apollo-client Steps to reproduce:
Related lines of code:
Commenting out this line does prevent the error. However if you navigate back to the unmounted scene the error property on CC @jbaxleyiii |
I'm experiencing this issue as well.
I'm not sure where to look for a solution / workaround for this. Wrapping with a HoC or using |
I will try to create a failing test case for this behaviour in the react-apollo repository, altough I think this might be an issue with apollo-client I cannot understand how I would reproduce this error by only using apollo-client. The current workaround solution that I am using is described in #1622 (use apollo-link-retry), which ironically might also be the best solution for my use case. Nevertheless this behaviour is a very critical issue for applications that could face flaky internet connections. |
Same problem here. Any failing request will throw an Unhandled exception in RN after you switch a route (unmount a component) |
This should be fixed in 2.1.0-beta.3 |
Correct! Query recycler is gone it seems :) |
As mentioned in #2258 (comment), this issue should now be resolved. Let us know if anyone is still encountering this problem. Thanks! |
When a component is unmounted, error observer is removed from the query (in graphql wrapper component function
componentWillUnmount
). Thus, if an "in flight" request arrives with an error, there is no way to catch it and avoid theconsole.error
red box message "Unhandled error ...".At least the error message should explain what's really happening (unmounting could keep an error observer subscribed to adapt the error message to this case).
The error message could also be removed or only be a
console.warn
.An option could be added to the
graphql
function to specify an error observer for errors after unmounting the wrapped component.The text was updated successfully, but these errors were encountered: