events: avoid retaining removed event names#64475
Merged
nodejs-github-bot merged 1 commit intoJul 13, 2026
Merged
Conversation
Contributor
|
Fast-track has been requested by @mcollina. Please 👍 to approve. |
ronag
approved these changes
Jul 13, 2026
jasnell
approved these changes
Jul 13, 2026
Restore shape mode for preallocated EventEmitters while deleting dynamic names from ordinary EventEmitters. Keeping every removed name as an undefined property causes unbounded memory growth when event names are unstructured. Refs: nodejs#64373 Signed-off-by: Matteo Collina <hello@matteocollina.com>
f0421ba to
ac80a3b
Compare
ronag
approved these changes
Jul 13, 2026
Collaborator
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64475 +/- ##
=======================================
Coverage 90.21% 90.22%
=======================================
Files 741 741
Lines 241608 241615 +7
Branches 45534 45523 -11
=======================================
+ Hits 217972 217987 +15
- Misses 15154 15158 +4
+ Partials 8482 8470 -12
🚀 New features to boost your workflow:
|
Collaborator
|
Landed in 35115c0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #64373.
That change retained removed listener keys with an
undefinedvalue for allEventEmitterinstances. With unstructured event names,_eventswould therefore grow without bound.This restores shape mode so preallocated emitters can retain their fixed keys while ordinary emitters delete dynamic keys or reset the events object. It also adds a regression test that adds and removes 100 unique event names and verifies they are not retained.