[v24.x backport] repl: keep reference count for process.on('newListener')#63194
Open
addaleax wants to merge 1 commit intonodejs:v24.x-stagingfrom
Open
[v24.x backport] repl: keep reference count for process.on('newListener')#63194addaleax wants to merge 1 commit intonodejs:v24.x-stagingfrom
process.on('newListener')#63194addaleax wants to merge 1 commit intonodejs:v24.x-stagingfrom
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
aduh95
approved these changes
May 8, 2026
Collaborator
Collaborator
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.
Had a whitespace-only conflict.
When investigating a memory leak in one of our applications, we discovered that this listener holds on to a
REPLServerinstance 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
REPLServerclass 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