writer.fail([reason])


把写入器置于终端错误状态。如果写入器已经关闭或出错,这个操作不会有任何效果。不同于 write() 和 end(),fail() 是无条件同步的,因为让写入器失败只是一个纯状态转换,没有异步操作需要执行。原因会被存储并原样传播。如果省略,原因默认为 undefined。

🌐 Put the writer into a terminal error state. If the writer is already closed or errored, this is a no-op. Unlike write() and end(), fail() is unconditionally synchronous because failing a writer is a pure state transition with no async work to perform. The reason is stored and propagated without modification. If omitted, the reason is undefined.