Skip to content

Commit f3c3771

Browse files
committed
docs: correct the end and readableEnded claims
`readableEnded` is also set on the paths that discard unread data, and the first `maybeDispatchEnd` call defers rather than emitting when data is buffered.
1 parent a2f8ac0 commit f3c3771

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

packages/interface/src/message-stream.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export interface MessageStreamEvents {
6868
remoteCloseWrite: Event
6969

7070
/**
71-
* The remote will send no more data and everything it sent has been read, so
72-
* resources tied to reading can be released.
71+
* No more data from the remote will be delivered, so resources tied to
72+
* reading can be released.
7373
*
7474
* Emitted at most once, when the read buffer empties after the remote closes
7575
* their writable end, or when `.abort` or `Stream.closeRead` close the
@@ -149,12 +149,11 @@ export interface MessageStream<Timeline extends MessageStreamTimeline = MessageS
149149

150150
/**
151151
* True once 'end' has been emitted. Read this instead of waiting for the
152-
* event, which fires only once and may already have passed. It is never set
153-
* if a stream closes with data left unread.
152+
* event, which fires only once and may already have passed.
154153
*
155154
* It does not mean the readable end is closed, or that the read buffer is
156-
* empty: data can be pushed back after 'end', for example by unwrapping a
157-
* byte stream that read ahead.
155+
* empty. Where the readable end is still open, data can be pushed back
156+
* after 'end', for example by unwrapping a byte stream that read ahead.
158157
*/
159158
readonly readableEnded: boolean
160159

packages/utils/src/abstract-message-stream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ export abstract class AbstractMessageStream<Timeline extends MessageStreamTimeli
539539
}
540540

541541
/**
542-
* Emit 'end' if nothing is buffered and no more data can arrive. Only the
543-
* first call has any effect
542+
* Emit 'end' if nothing is buffered and no more data will be delivered.
543+
* Emits at most once
544544
*/
545545
protected maybeDispatchEnd (): void {
546546
if (this.#readableEnded || this.readBuffer.byteLength > 0) {

0 commit comments

Comments
 (0)