From ba0a82a1e11aee503c8808ce4d675d9e97effe7a Mon Sep 17 00:00:00 2001 From: Kit Dallege Date: Tue, 17 Mar 2026 17:03:11 +0100 Subject: [PATCH] doc: clarify fs.ReadStream and fs.WriteStream are not constructable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/issues/40546 Co-Authored-By: Claude Opus 4.6 PR-URL: https://github.com/nodejs/node/pull/62208 Reviewed-By: René Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen --- doc/api/fs.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 032918659e6..18464b76a2d 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -7138,8 +7138,8 @@ added: v0.1.93 * Extends: {stream.Readable} -Instances of {fs.ReadStream} are created and returned using the -[`fs.createReadStream()`][] function. +Instances of {fs.ReadStream} cannot be constructed directly. They are created and +returned using the [`fs.createReadStream()`][] function. #### Event: `'close'` @@ -7909,8 +7909,8 @@ added: v0.1.93 * Extends {stream.Writable} -Instances of {fs.WriteStream} are created and returned using the -[`fs.createWriteStream()`][] function. +Instances of {fs.WriteStream} cannot be constructed directly. They are created and +returned using the [`fs.createWriteStream()`][] function. #### Event: `'close'`