Skip to content

test: add validation for listener removal in read streams - #65421

Open
Paraspandey-debugs wants to merge 1 commit into
nodejs:mainfrom
Paraspandey-debugs:main
Open

test: add validation for listener removal in read streams#65421
Paraspandey-debugs wants to merge 1 commit into
nodejs:mainfrom
Paraspandey-debugs:main

Conversation

@Paraspandey-debugs

Copy link
Copy Markdown

Add a regression test covering the listener leak reported in #64214,
where repeated fileHandle.createReadStream({ autoClose: false, ... })
calls each attach a 'close' listener to the FileHandle that is never
removed once the stream ends. Over many ranged reads on a long-lived
handle this triggers MaxListenersExceededWarning and leaks memory.

The test creates 100 short-lived ranged read streams from a single
FileHandle and asserts that the FileHandle's 'close' listener count
returns to its pre-loop baseline after each stream is fully consumed.

A previous fix (#64227) was merged and then reverted (#65387) after
introducing a separate issue where a stream's reference on the
FileHandle could be released more than once. This PR adds test
coverage for the originally reported listener leak only.

Refs: #64214
Refs: #64227
Refs: #65387

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants