Version
26.1.0
Platform
Subsystem
stream
What steps will reproduce the bug?
import { throws } from "assert";
import { Writable } from "stream";
import { fromWritable } from "stream/iter";
const writable = new Writable({
highWaterMark: 1,
write(chunk, enc, cb) {
// Keep the internal buffer full.
},
});
// First call creates and caches the default strict writer.
fromWritable(writable);
// Bug 1: invalid options are ignored because the cached writer is returned
// before options are validated.
throws(() => fromWritable(writable, { backpressure: "invalid" }), {
code: "ERR_INVALID_ARG_VALUE",
});
// Bug 2: later valid options are ignored too. This should create/use a
// drop-newest writer, but currently returns the cached strict writer.
const writer = fromWritable(writable, { backpressure: "drop-newest" });
await writer.write("a");
// Expected: resolves and drops the chunk.
// Actual: rejects with ERR_INVALID_STATE from strict backpressure.
await writer.write("b");
writable.destroy();
node --experimental-stream-iter repro.js
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No assertion failure, second write resolves.
What do you see instead?
The invalid option does not throw.
If you remove the throws() block, the second write rejects as strict backpressure.
Additional information
No response
Version
26.1.0
Platform
Subsystem
stream
What steps will reproduce the bug?
node --experimental-stream-iter repro.jsHow often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No assertion failure, second write resolves.
What do you see instead?
The invalid option does not throw.
If you remove the throws() block, the second write rejects as strict backpressure.
Additional information
No response