You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stream/iter: fromWritable().writev() leaves Writable corked when chunk validation throws #63294
import{strictEqual,throws}from"node:assert";import{Writable}from"node:stream";import{fromWritable}from"node:stream/iter";constwritable=newWritable({write(chunk,enc,cb){cb();},});constwriter=fromWritable(writable);throws(()=>writer.writev([newUint8Array([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.
Activity
stream: uncork fromWritable writev on chunk error
stream: uncork fromWritable writev on chunk error
stream: uncork fromWritable writev on chunk error
stream: uncork fromWritable writev on chunk error