◐ Shell
clean mode source ↗

[v24.x backport] repl: keep reference count for `process.on('newListener')` by addaleax · Pull Request #63194 · nodejs/node

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 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

@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