Skip to content
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

Don't report errors errors as unhandled if there is an existing "error" event handler #4767

Merged
merged 8 commits into from
Oct 26, 2017

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Oct 26, 2017

This add a failing integration test for behavior React relies on.
It passes before #4669, but now fails.

Demonstrates Fixes #4764.

@SimenB
Copy link
Member

SimenB commented Oct 26, 2017

Heh, we fixed lint at the same time

@SimenB
Copy link
Member

SimenB commented Oct 26, 2017

Bah, rest args is not available on node 4. Needs arguments. I'll take a step back so we don't try to double fix stuff

@gaearon
Copy link
Contributor Author

gaearon commented Oct 26, 2017

Lol. I pushed a commit that tracks the number of user handlers. I think it's more correct because if the user removes the listener, we should restore the original behavior.

@gaearon gaearon changed the title Add failing integration test for rethrowing after nested event loop Don't report errors errors as unhandled if there is an existing "error" event handler Oct 26, 2017
if (name === 'error') {
userErrorListenerCount--;
}
return originalRemoveListener.apply(this, arguments);
Copy link
Member

@SimenB SimenB Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be .apply(global, arguments) as this is wrong in the arrow function, right?

arguments is also wrong within the arrow

this.errorEventListener = event => {
if (event.error) {
if (userErrorListenerCount === 0 && event.error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of manual bookkeeping, can we just check the total number of listeners here?

e.g. this works in chrome:

window.getEventListeners(window).error.length // 1 on github.com

Copy link
Member

@SimenB SimenB Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like getEventListeners is not available for jsdom@9 at least

EDIT: Or in 11

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with upgrading to 11 and dropping node 4 now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jest master doesn't seem to catch errors originating from React
4 participants