Skip to content

doc: clarify fs.ReadStream and fs.WriteStream are not constructable#62208

Open
kovan wants to merge 2 commits intonodejs:mainfrom
kovan:doc-fs-stream-constructor
Open

doc: clarify fs.ReadStream and fs.WriteStream are not constructable#62208
kovan wants to merge 2 commits intonodejs:mainfrom
kovan:doc-fs-stream-constructor

Conversation

@kovan
Copy link
Contributor

@kovan kovan commented Mar 11, 2026

Add explicit wording that fs.ReadStream and fs.WriteStream
should not be constructed directly, matching the existing pattern
used by fs.Stats ("not to be created directly using the new
keyword"). The factory functions fs.createReadStream() and
fs.createWriteStream() are the supported API.

Verified against lib/internal/fs/streams.js — the constructors
exist as plain functions with new guards, but are not documented
as public constructors.

Fixes: #40546

Add explicit wording that fs.ReadStream and fs.WriteStream should not
be constructed directly, matching the existing pattern used by fs.Stats
("not to be created directly using the new keyword"). The factory
functions fs.createReadStream() and fs.createWriteStream() are the
supported API.

Fixes: nodejs#40546

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Mar 11, 2026
doc/api/fs.md Outdated
Comment on lines +7150 to +7151
Instances of {fs.ReadStream} are created and returned using the
[`fs.createReadStream()`][] function.
`fs.ReadStream` is not to be constructed directly; use
[`fs.createReadStream()`][] instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues in principle, but I think this would scan better as a combination of your wording and the original wording, eg.

Instances of {fs.ReadStream} cannot be constructed directly. They are created and
returned using the [`fs.createReadStream()`][] function.

…table

apply reviewer suggestion: combine wording
@Renegade334 Renegade334 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 14, 2026
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. doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc: fs.ReadStream and fs.WriteStream public/private clarification

4 participants