Skip to content

[v24.x backport] repl: keep reference count for process.on('newListener')#63194

Open
addaleax wants to merge 1 commit intonodejs:v24.x-stagingfrom
addaleax:backport-61895-v24.x
Open

[v24.x backport] repl: keep reference count for process.on('newListener')#63194
addaleax wants to merge 1 commit intonodejs:v24.x-stagingfrom
addaleax:backport-61895-v24.x

Conversation

@addaleax
Copy link
Copy Markdown
Member

@addaleax addaleax commented May 8, 2026

Had a whitespace-only conflict.


When investigating a memory leak in one of our applications, we discovered that this listener holds on to a REPLServer instance and all heap objects transitively kept alive by it by capturing as part of its closure.

It's cleaner to declare the listener outside of the REPLServer class and to actually clean it up properly when it is no longer required or meaningful, which is easily achieved through keeping a reference count.

PR-URL: #61895
Reviewed-By: Colin Ihrig cjihrig@gmail.com
Reviewed-By: Luigi Pinca luigipinca@gmail.com

When investigating a memory leak in one of our applications,
we discovered that this listener holds on to a `REPLServer`
instance and all heap objects transitively kept alive by it
by capturing as part of its closure.

It's cleaner to declare the listener outside of the `REPLServer`
class and to actually clean it up properly when it is no longer
required or meaningful, which is easily achieved through
keeping a reference count.

PR-URL: nodejs#61895
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch. labels May 8, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.86%. Comparing base (c989497) to head (c8a4b3c).
⚠️ Report is 478 commits behind head on v24.x-staging.

Additional details and impacted files
@@                Coverage Diff                @@
##           v24.x-staging   #63194      +/-   ##
=================================================
- Coverage          90.06%   89.86%   -0.21%     
=================================================
  Files                672      680       +8     
  Lines             201174   207886    +6712     
  Branches           39304    39996     +692     
=================================================
+ Hits              181197   186821    +5624     
- Misses             12240    13267    +1027     
- Partials            7737     7798      +61     
Files with missing lines Coverage Δ
lib/repl.js 94.26% <100.00%> (+0.05%) ⬆️

... and 208 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.

@aduh95 aduh95 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 May 8, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 8, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

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. repl Issues and PRs related to the REPL subsystem. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants