@@ -409,7 +409,7 @@ complete:
409409if (! writer .writeSync (chunk)) await writer .write (chunk);
410410if (! writer .writevSync (chunks)) await writer .writev (chunks);
411411if (writer .endSync () < 0 ) await writer .end ();
412- if ( ! writer .failSync (err)) await writer . fail (err);
412+ writer .fail (err); // Always synchronous, no fallback needed
413413```
414414
415415### ` writer.desiredSize `
@@ -446,18 +446,12 @@ if (result < 0) {
446446
447447### ` writer.fail(reason) `
448448
449- * ` reason ` {Error}
450- * Returns: {Promise\< void>}
451-
452- Fail the stream with an error.
453-
454- ### ` writer.failSync(reason) `
455-
456- * ` reason ` {Error}
457- * Returns: {boolean} ` true ` if the writer was failed, ` false ` if already
458- errored.
449+ * ` reason ` {any}
459450
460- Synchronous variant of ` writer.fail() ` .
451+ Put the writer into a terminal error state. If the writer is already closed
452+ or errored, this is a no-op. Unlike ` write() ` and ` end() ` , ` fail() ` is
453+ unconditionally synchronous because failing a writer is a pure state
454+ transition with no async work to perform.
461455
462456### ` writer.write(chunk[, options]) `
463457
@@ -604,10 +598,10 @@ Pipe a source through transforms into a writer. If the writer has a
604598scatter/gather I/O).
605599
606600If the writer implements the optional ` *Sync ` methods (` writeSync ` , ` writevSync ` ,
607- ` endSync ` , ` failSync ` ), ` pipeTo() ` will attempt to use the synchronous methods
601+ ` endSync ` ), ` pipeTo() ` will attempt to use the synchronous methods
608602first as a fast path, and fall back to the async versions only when the sync
609603methods indicate they cannot complete (e.g., backpressure or waiting for the
610- next tick).
604+ next tick). ` fail() ` is always called synchronously.
611605
612606``` mjs
613607import { from , pipeTo , compressGzip } from ' node:stream/iter' ;
@@ -655,7 +649,7 @@ Synchronous version of [`pipeTo()`][]. The `source`, all transforms, and the
655649` writer ` must be synchronous. Cannot accept async iterables or promises.
656650
657651The ` writer ` must have the ` *Sync ` methods (` writeSync ` , ` writevSync ` ,
658- ` endSync ` , ` failSync ` ) for this to work.
652+ ` endSync ` ) and ` fail() ` for this to work.
659653
660654### ` pull(source[, ...transforms][, options]) `
661655
0 commit comments