Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d41b0d1
stream: call stateless iter transforms without this
jasnell Nov 29, 2026
d529649
stream: enforce the range of iter budget options
jasnell Nov 29, 2026
1efcbc3
stream: reject on iter Writer argument errors
jasnell Nov 29, 2026
f6d0e75
stream: throw a TypeError on incomplete pipeToSync() close
jasnell Nov 29, 2026
e02e910
stream: fail the broadcast writer when its signal aborts
jasnell Nov 29, 2026
a4e9a2e
stream: finish iter consumers of a cancelled broadcast
jasnell Nov 29, 2026
dcd5352
stream: add stream/iter broadcastFrom()
jasnell Nov 29, 2026
e764b97
stream: honor share protocols in stream/iter share()
jasnell Nov 29, 2026
f995d5b
stream: bound streamable conversions in stream/iter from()
jasnell Nov 29, 2026
efcfa1f
stream: accept function drainables in stream/iter ondrain()
jasnell Nov 29, 2026
a249fa3
stream: copy shared and resizable memory in stream/iter
jasnell Nov 29, 2026
3148222
stream: accept buffer sources in stream/iter writers
jasnell Nov 29, 2026
d361c71
stream: add a lazy signal to stream/iter writers
jasnell Nov 29, 2026
6f1048d
stream: throw the stop reason from stream/iter pipeToSync()
jasnell Nov 29, 2026
fa8f136
stream: add abort() to stream/iter duplex channels
jasnell Nov 29, 2026
bec4003
stream: treat an undefined cancel reason as absent in stream/iter
jasnell Nov 29, 2026
d7a1b7e
stream: normalize stream/iter transform output like from()
jasnell Nov 29, 2026
3ba205a
stream: default the stream/iter writer fail() reason
jasnell Nov 29, 2026
05072ea
stream: resolve stream/iter end() once all data is delivered
jasnell Nov 29, 2026
adf4928
stream: deliver buffered broadcast data after writer fail()
jasnell Nov 29, 2026
976b38c
stream: settle pending next() on stream/iter merge() return()
jasnell Nov 29, 2026
f32f574
stream: reject promises from stream/iter toStreamable
jasnell Nov 29, 2026
0f283fe
stream: settle pending next() on stream/iter return()
jasnell Nov 29, 2026
87ab9b8
stream: check an aborted signal first in stream/iter multi-consumers
jasnell Nov 29, 2026
133e8bb
stream: queue stream/iter throw() behind pending next()
jasnell Nov 29, 2026
5e64229
quic: follow the stream/iter drain protocol in stream writers
jasnell Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1093,15 +1093,16 @@ added:
performance. **Default:** `131072` (128 KB).
* Returns: {Object}
* `write(chunk[, options])` {Function} Returns {Promise}.
Accepts `Uint8Array`, `Buffer`, or string (UTF-8 encoded).
* `chunk` {Buffer|TypedArray|DataView|string}
Accepts any `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `DataView`,
or `Buffer`, or a string (UTF-8 encoded).
* `chunk` {Buffer|TypedArray|DataView|ArrayBuffer|SharedArrayBuffer|string}
* `options` {Object}
* `signal` {AbortSignal} If the signal is already aborted, the write
rejects with `AbortError` without performing I/O.
* `writev(chunks[, options])` {Function} Returns {Promise}. Uses
scatter/gather I/O via a single `writev()` syscall. Accepts mixed
`Uint8Array`/string arrays.
* `chunks` {Buffer\[]|TypedArray\[]|DataView\[]|string\[]}
arrays of the same chunk types as `write()`.
* `chunks` {Buffer\[]|TypedArray\[]|DataView\[]|ArrayBuffer\[]|SharedArrayBuffer\[]|string\[]}
* `options` {Object}
* `signal` {AbortSignal} If the signal is already aborted, the write
rejects with `AbortError` without performing I/O.
Expand All @@ -1110,10 +1111,10 @@ added:
should fall back to async `write()`. Returns `false` when: the writer
is closed/errored, an async operation is in flight, the chunk exceeds
`chunkSize`, or the write would exceed `limit`.
* `chunk` {Buffer|TypedArray|DataView|string}
* `chunk` {Buffer|TypedArray|DataView|ArrayBuffer|SharedArrayBuffer|string}
* `writevSync(chunks)` {Function} Returns {boolean}. Synchronous batch
write. Same fallback semantics as `writeSync()`.
* `chunks` {Buffer\[]|TypedArray\[]|DataView\[]|string\[]}
* `chunks` {Buffer\[]|TypedArray\[]|DataView\[]|ArrayBuffer\[]|SharedArrayBuffer\[]|string\[]}
* `end([options])` {Function} Returns {Promise}, fulfills with the total
number of bytes written. Idempotent: returns `totalBytesWritten` if already
closed, returns the pending promise if already closing. Rejects if the writer
Expand All @@ -1127,6 +1128,8 @@ added:
* `fail(reason)` {Function} Puts the writer into a terminal error state.
Synchronous. If the writer is already closed or errored, this is a
no-op. If `autoClose` is true, closes the file handle synchronously.
Pending and later writes, and `end()`, reject with `reason`. If `reason`
is omitted or `undefined`, it is an `AbortError` {DOMException}.

Return a [`node:stream/iter`][] writer backed by this file handle.

Expand Down
31 changes: 19 additions & 12 deletions doc/api/quic.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ There are two ways to write data to a stream:
(`write()`, `writev()`, `end()`). The asynchronous `write()` and `writev()`
methods use the stream/iter strict backpressure policy: when the write buffer
is full, they reject with `ERR_INVALID_STATE` instead of waiting for capacity.
If a drain is already pending, `end()` waits for it before closing. Check
`writer.canWrite` before writing. To wait for capacity, use `ondrain()` from
`node:stream/iter`, then retry the write. The stream's `onblocked` callback
If a write is waiting for capacity, `end()` waits for it before closing.
Check `writer.canWrite` before writing. To wait for capacity, use
`ondrain()` from `node:stream/iter`, then retry the write. The stream's `onblocked` callback
reports that transport flow control has blocked progress, but does not
signal that writer capacity is available again.
`writeSync()` returns `false` when the write buffer is full; the caller
Expand Down Expand Up @@ -2512,9 +2512,11 @@ The Writer has the following methods:
`ERR_INVALID_STATE` when the stream is flow-controlled rather than waiting
for capacity.
* `endSync()` — Synchronous close. Returns total bytes or `-1`.
* `end([options])` — Async close. If a drain is already pending, waits for it
before closing.
* `end([options])` — Async close. If a write is waiting for capacity, waits
for it before closing. Pending `ondrain()` promises resolve with `false`.
* `fail(reason)` — Errors the stream (sends `RESET_STREAM` to peer).
Later writes and `end()` reject with `reason`, or with an `AbortError`
{DOMException} if `reason` is omitted or `undefined`.
When `reason` is a [`QuicError`][], its [`error.errorCode`][] is used
as the wire code on the resulting `RESET_STREAM` frame; otherwise
the wire code falls back to the negotiated application protocol's
Expand All @@ -2523,18 +2525,23 @@ The Writer has the following methods:
See [`stream.destroy()`][] for a full-stream abort that also resets
the readable side via `STOP_SENDING`.
* `canWrite` — `true` if writes will be accepted, `false` if at capacity,
or `null` if closed/errored. When `writeSync()` returns `false`, use
`ondrain()` from `node:stream/iter` to wait before retrying. If `ondrain()`
returns `null`, no drain wait is available and the write should not be
retried.
or `null` if closing, closed or errored. When `writeSync()` returns
`false`, use `ondrain()` from `node:stream/iter` to wait before retrying.

The Writer implements the drainable protocol used by `ondrain()`, as the
writers of `node:stream/iter` do. `ondrain(writer)` returns `null` when
`writer.canWrite` is `null`: no drain wait is available and the write should
not be retried. Otherwise it returns a promise that resolves with `true`
once the stream has capacity (at once if it has capacity already), resolves
with `false` if the writer is ended first, and rejects if the writer fails
first, by `fail()` or because the peer sent `STOP_SENDING`.

```mjs
import { ondrain } from 'node:stream/iter';

while (!writer.writeSync(chunk)) {
const drain = ondrain(writer);
if (drain === null) break;
await drain;
// Null once the writer is closed or errored, false once it is ended.
if (!await ondrain(writer)) break;
}
```

Expand Down
Loading
Loading