question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error handling for unmounted component

See original GitHub issue

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 the console.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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

9reactions
GuillemotFcommented, Nov 20, 2017

I made a reproduction with the error template It reproduces a component throwing an unhandled network error when unmounting and not updating after an error (related to #2513)

5reactions
monotvcommented, Nov 22, 2017

An unhandled network error when unmounting a component that failed to fetch this in particular is killing Apollo for me. The docs suggest logging the user out on a 401 error. Logging out often means unmounting scenes. This results in an unhandled error. So the docs are contradicted by how the client behaves.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't perform a React state update on an unmounted ...
and then I was trying to show a message with this.setState({succ_message: "...") in my component. Component was looking empty with the same ...
Read more >
Fixing React's “Called SetState() on an ... - How-To Geek
Seeing Called setState() on an Unmounted Component in your console is one of the most frequent issues faced by newcomers to React.
Read more >
React: Prevent state updates on unmounted components
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your...
Read more >
Avoid React state update warnings on unmounted components
React raising a warning when you try to perform a state update on an unmounted component. React setState is used to update the...
Read more >
React state update on an unmounted component - debuggr.io
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found