-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Open
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Affected URL(s)
https://nodejs.org/dist/latest-v16.x/docs/api/stream.html#readablepipedestination-options
Description of the problem
The linked docs say:
One important caveat is that if the
Readablestream emits an error during processing, theWritabledestination is not closed automatically. If an error occurs, it will be necessary to manually close each stream in order to prevent memory leaks.
It seems like it does close/destroy the writable. See below test. I can't find any tests that assert that it's not closed.
import stream from "node:stream";
import {finished} from "node:stream/promises";
import assert from "node:assert";
class NullWritable extends stream.Writable {
_write(c, e, cb) { cb(); }
}
const src = stream.Readable.from(["1", "2", "3"]);
const dest = new NullWritable();
const theError = new Error("aborted");
src.pipe(dest);
process.nextTick(() => src.emit("error", theError)); // Emit an error during processing
await assert.rejects(finished(src));
assert.strictEqual(src.destroyed, true);
assert.strictEqual(dest.destroyed, false); // This is true; docs suggest it would be falseReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.