Version
26.1.0
Platform
Subsystem
stream
What steps will reproduce the bug?
import { strictEqual, throws } from "node:assert";
import { Writable } from "node:stream";
import { fromWritable } from "node:stream/iter";
const writable = new Writable({
write(chunk, enc, cb) {
cb();
},
});
const writer = fromWritable(writable);
throws(() => writer.writev([new Uint8Array([1]), 42]), {
code: "ERR_INVALID_ARG_TYPE",
});
// Expected: writev() should uncork even when a later chunk conversion throws.
strictEqual(writable.writableCorked, 0);
Run with
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?
fromWritable().writev() should either complete the batched write or throw/reject without changing the underlying Writableβs corking state. If writev() internally calls writable.cork(), it should always pair that with writable.uncork(), including when converting or validating a later chunk throws.
What do you see instead?
Calling writer.writev([new Uint8Array([1]), 42]) throws ERR_INVALID_ARG_TYPE, but the wrapped classic Writable remains corked afterward (writable.writableCorked === 1). This happens because writev() corks before converting all chunks, and if toUint8Array() throws for a later chunk, the uncork() call is skipped.
Additional information
No response
Version
26.1.0
Platform
Subsystem
stream
What steps will reproduce the bug?
Run with
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?
fromWritable().writev()should either complete the batched write or throw/reject without changing the underlyingWritableβs corking state. Ifwritev()internally callswritable.cork(), it should always pair that withwritable.uncork(), including when converting or validating a later chunk throws.What do you see instead?
Calling
writer.writev([new Uint8Array([1]), 42])throwsERR_INVALID_ARG_TYPE, but the wrapped classicWritableremains corked afterward (writable.writableCorked === 1). This happens becausewritev()corks before converting all chunks, and iftoUint8Array()throws for a later chunk, theuncork()call is skipped.Additional information
No response