Skip to content

fs: fix close listener leak in FileHandle streams#64227

Open
Y1D7NG wants to merge 1 commit into
nodejs:mainfrom
Y1D7NG:fix-stream-leak
Open

fs: fix close listener leak in FileHandle streams#64227
Y1D7NG wants to merge 1 commit into
nodejs:mainfrom
Y1D7NG:fix-stream-leak

Conversation

@Y1D7NG

@Y1D7NG Y1D7NG commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

fix: #64214

When autoClose is false, FileHandle.createReadStream registers a close listener on the handle. That listener is not removed after the stream finishes normally, so creating streams repeatedly on the same handle accumulates listeners.

In importFd, when autoClose is false, remove that listener and perform the corresponding unref cleanup when the stream ends (on end for read streams, on finish for write streams) or on error.

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jul 1, 2026
@Y1D7NG Y1D7NG force-pushed the fix-stream-leak branch 5 times, most recently from b433fb3 to c4a165a Compare July 1, 2026 11:11
Fixes: nodejs#64214
Signed-off-by: y1d7ng <y1d7ng@yeah.net>
@Y1D7NG Y1D7NG force-pushed the fix-stream-leak branch from c4a165a to 96cae83 Compare July 1, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Close listener leak in fs/promises createReadStream

2 participants