Repository navigation
events: separate Node-style dispatch from passive event cleanup - #67709
ethanresnick wants to merge 1 commit into
Conversation
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
040a906 to
9b2945a
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The regression test can pass even if rejection handling is removed because it does not assert the exception origin to distinguish explicit error forwarding from an unhandled rejection.
1 open issue
What changed in this PR
This PR separates Node-style and DOM-style dispatch in the internal EventTarget implementation, avoiding passive-state property access on arbitrary Node payloads while preserving DOM event cleanup.
Changes:
- Moves Node-style callback invocation into a separate branch, keeping passive-state handling in the DOM branch.
- Adds regression tests for Proxy payloads, once listeners, mixed listener types, passive cancellation, and callback error handling.
| File | Description |
|---|---|
test/parallel/test-eventtarget-node-payload.js |
Adds payload, listener cleanup, and error-routing regression tests. |
lib/internal/event_target.js |
Separates dispatch paths to avoid passive-state checks on Node payloads. |
Review effort: Balanced
Signed-off-by: Ethan Resnick <ethan.resnick@gmail.com>
9b2945a to
0a65ff2
Compare

EventTarget's hybrid dispatcher currently checks the passive-listener symbol on the callback argument in a sharedfinallyblock. For Node-style listeners that argument is an arbitrary payload, rather than a DOMEvent. This PR splits the work into Node-style and DOM-style branches using the existing listener-type decision, so that limiting passive state management entirely to the DOM branch.The main goal is to increase performance: the symbol lookup on arbitrary, non-Event payloads is unnecessary and, in my codebase, it caused a lot of v8 code recompilations, because the symbol lookup happens on so many different payload shapes.
However, the lookup in the current code could also invoke a Proxy trap on the payload object, which probably isn’t intentional or desirable, so the semantics of this version may be better in that respect too.
The PR add regression coverage for untouched Proxy payloads, once listeners, mixed Node/DOM listeners, passive cancellation cleanup, thrown callback errors, and rejected callback returns.
Searched open PRs for passive-listener cleanup and
kInPassiveListener; no duplicate was found. No directly matching issue was identified.The code in this PR was generated by a frontier model, but I’ve reviewed it thoroughly.