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 event fired twice when in development mode #12093
Comments
I think it has something to do with invokeGuardedCallback. in // To preserve the expected "Pause on exceptions" behavior, we don't use a
// try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
// DOM node, and call the user-provided callback from inside an event handler
// for that fake event. If the callback throws, the error is "captured" using
// a global event handler. But because the error happens in a different
// event loop context, it does not interrupt the normal program flow.
// Effectively, this gives us try-catch behavior without actually using
// try-catch. Neat! This is more like the intended behavior and not a bug. |
Hey @aulisius thanks for your reply :) I understand the intention of preserving the expected "Pause on exceptions" behaviour of the dev tools, I doubt the react developers expect an user defined error event listener to be invoked twice with the same instance of the error though. I'm not even sure As an extra info I've also noticed that 'error' events are fired twice while 'unhandledrejection' events behave correctly |
I think this is a duplicate of #10474. |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Error event fired twice when in development mode.
In the example you can see that '>>>>>>error' is logged twice while I only expect to see it once.
Note: this issue doesn't happen with the production version of react
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
https://codepen.io/anon/pen/ppXZXP?editors=0011
static html reproducing the problem:
What is the expected behavior?
I expect to see '>>>>>>error' logged once
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
reproduced on:
react v16.2.0
Chrome 63.0.3239.132
OSX 10.10.5
The text was updated successfully, but these errors were encountered: