From 10646ba16ba63682206df93f70a0e30cf7d4b4ad Mon Sep 17 00:00:00 2001 From: kovan Date: Wed, 11 Mar 2026 11:36:12 +0100 Subject: [PATCH 1/2] doc: clarify fs.ReadStream and fs.WriteStream are not constructable 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 --- 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 66d29bc80fbf18..78001e25d4d87c 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -7147,8 +7147,8 @@ added: v0.1.93 * Extends: {stream.Readable} -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. #### Event: `'close'` @@ -7918,8 +7918,8 @@ added: v0.1.93 * Extends {stream.Writable} -Instances of {fs.WriteStream} are created and returned using the -[`fs.createWriteStream()`][] function. +`fs.WriteStream` is not to be constructed directly; use +[`fs.createWriteStream()`][] instead. #### Event: `'close'` From 74287d8edb6dd93d8f7a29395ed935e7c686f3de Mon Sep 17 00:00:00 2001 From: kovan Date: Sat, 14 Mar 2026 20:33:01 +0100 Subject: [PATCH 2/2] fixup! doc: clarify fs.ReadStream and fs.WriteStream are not constructable apply reviewer suggestion: combine wording --- 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 78001e25d4d87c..c5e6387d1e4e20 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -7147,8 +7147,8 @@ added: v0.1.93 * Extends: {stream.Readable} -`fs.ReadStream` is not to be constructed directly; use -[`fs.createReadStream()`][] instead. +Instances of {fs.ReadStream} cannot be constructed directly. They are created and +returned using the [`fs.createReadStream()`][] function. #### Event: `'close'` @@ -7918,8 +7918,8 @@ added: v0.1.93 * Extends {stream.Writable} -`fs.WriteStream` is not to be constructed directly; use -[`fs.createWriteStream()`][] instead. +Instances of {fs.WriteStream} cannot be constructed directly. They are created and +returned using the [`fs.createWriteStream()`][] function. #### Event: `'close'`