Skip to content

events: avoid retaining removed event names#64475

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:fix-event-emitter-unstructured-names
Jul 13, 2026
Merged

events: avoid retaining removed event names#64475
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:fix-event-emitter-unstructured-names

Conversation

@mcollina

Copy link
Copy Markdown
Member

Follow-up to #64373.

That change retained removed listener keys with an undefined value for all EventEmitter instances. With unstructured event names, _events would 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.

@mcollina mcollina requested a review from ronag July 13, 2026 16:17
@nodejs-github-bot nodejs-github-bot added events Issues and PRs related to the events subsystem / EventEmitter. needs-ci PRs that need a full CI run. labels Jul 13, 2026
@mcollina mcollina added the fast-track PRs that do not need to wait for 72 hours to land. label Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Fast-track has been requested by @mcollina. Please 👍 to approve.

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>
@mcollina mcollina force-pushed the fix-event-emitter-unstructured-names branch from f0421ba to ac80a3b Compare July 13, 2026 16:20
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 13, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 13, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.22%. Comparing base (384d7a4) to head (ac80a3b).
⚠️ Report is 7 commits behind head on main.

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     
Files with missing lines Coverage Δ
lib/events.js 99.60% <100.00%> (+<0.01%) ⬆️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 13, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 13, 2026
@nodejs-github-bot nodejs-github-bot merged commit 35115c0 into nodejs:main Jul 13, 2026
70 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 35115c0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

events Issues and PRs related to the events subsystem / EventEmitter. fast-track PRs that do not need to wait for 72 hours to land. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants