GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — events: report original once() listener on removal by vedchaudhari · Pull Request #66621 · nodejs/node Conversation
Contributor
If a const EventEmitter = require('node:events'); function f() {} function g() {} const ee = new EventEmitter(); ee.once('x', f); ee.on('x', g); ee.on('removeListener', (type, listener) => console.log(listener === f)); ee.emit('x'); // before: false (listener is the internal wrapper) // after: true This was fixed in #6394 (2016) and documented, but #33596 (2020) removed the unwrapping from the multi-listener path. The existing test only used a single listener, so CI didn't catch it. This unwraps the listener the same way the single-listener path already does, and adds a test with a second listener. The stream, domain and event tests pass. Benchmark: events/ee-add-remove.js (30 runs)The changed line only runs when a I used Claude Code to find the bug and write the fix and test. I reproduced it, reviewed the change, and ran the tests and benchmark myself.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsWhen a `once()` listener is removed, emit the original user-defined function in the `removeListener` event instead of the internal wrapper, matching the behavior of the single-listener path. Assisted-by: claude:opus-5.5 Signed-off-by: vedchaudhari <[email protected]>
|
There was an error while loading. Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## main #66621 +/- ## ========================================== - Coverage 92.78% 90.42% -2.36% ========================================== Files 422 791 +369 Lines 193692 276585 +82893 Branches 29881 53114 +23233 ========================================== + Hits 179714 250110 +70396 - Misses 13650 16872 +3222 - Partials 328 9603 +9275
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mcollina Could you please take a look when you get a chance? This fixes a regression from #33596: with two or more listeners, the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@lpinca would you have a moment to take a look? It fixes the 'removeListener' |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@gurgunday since you reviewed #60137, would you have a moment to look at this one? It fixes the same |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Landed in 98dbf60 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When a `once()` listener is removed, emit the original user-defined function in the `removeListener` event instead of the internal wrapper, matching the behavior of the single-listener path. Assisted-by: claude:opus-5.5 Signed-off-by: vedchaudhari <[email protected]> PR-URL: #66621 Refs: #5551 Refs: #6394 Refs: #33596 Reviewed-By: Chemi Atlow <[email protected]>
When a `once()` listener is removed, emit the original user-defined function in the `removeListener` event instead of the internal wrapper, matching the behavior of the single-listener path. Assisted-by: claude:opus-5.5 Signed-off-by: vedchaudhari <[email protected]> PR-URL: nodejs#66621 Refs: nodejs#5551 Refs: nodejs#6394 Refs: nodejs#33596 Reviewed-By: Chemi Atlow <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.