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

events: allow dispatch many times without listener #39772

Closed

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Aug 15, 2021

This fixes an issue where the fast path of EventTarget's hybrid dispatch (for when there aren't any listeners attached) didn't reset the kIsBeingDispatchedFlag, meaning an event couldn't be dispatched multiple times:

const target = new EventTarget();
const event = new Event("test");
target.dispatchEvent(event);
target.dispatchEvent(event); // Uncaught Error [ERR_EVENT_RECURSION]: The event "test" is already being dispatched

Fast path for EventTarget dispatch with no listeners didn't reset
kIsBeingDispatched flag, meaning same event couldn't be dispatched
multiple times.

Refs: nodejs#39395
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Aug 15, 2021
@nodejs-github-bot
Copy link
Collaborator

@Ayase-252 Ayase-252 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Sep 26, 2021
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 26, 2021
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

lpinca pushed a commit that referenced this pull request Sep 26, 2021
Fast path for EventTarget dispatch with no listeners didn't reset
kIsBeingDispatched flag, meaning same event couldn't be dispatched
multiple times.

PR-URL: #39772
Refs: #39395
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@lpinca
Copy link
Member

lpinca commented Sep 26, 2021

Landed in b381bed.

@lpinca lpinca closed this Sep 26, 2021
@mrbbot mrbbot deleted the fix/event-target-reset-no-listeners branch September 26, 2021 19:25
targos pushed a commit that referenced this pull request Oct 4, 2021
Fast path for EventTarget dispatch with no listeners didn't reset
kIsBeingDispatched flag, meaning same event couldn't be dispatched
multiple times.

PR-URL: #39772
Refs: #39395
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants