Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions js/net/src/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,11 @@ export class Consumer {

/** Closes the group, optionally with an error to abort readers. Idempotent. */
close(abort?: Error) {
// A copy failure recovery was continuing past ends with the abort instead.
if (abort && this.#recover && this.#state.closed.peek() instanceof Error) {
this.#terminal ??= abort;
if (this.#verdict.peek() === undefined) this.#verdict.set(this.#terminal);
}
this.#abandon();
this.#recover = undefined;
// Closing is terminal for this reader, even with frames still unread.
Expand Down
10 changes: 9 additions & 1 deletion js/net/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export interface ResumeSource {
latest(): number | undefined;
/** The serving copy's declared start, raised to its cursor floor, or `"pending"` until resolved. */
start(): number | "pending" | undefined;
/** The serving copy's declared exclusive end. */
/** The logical track's declared exclusive end, as the first copy to know it declared it. */
end(): Location | undefined;
/** Resolve with the logical track's exclusive end once known. */
finished(): Promise<Location>;
Expand Down Expand Up @@ -469,6 +469,11 @@ export const hooks: {
tryRecvDatagram: (subscriber: Subscriber) => RecvDatagram;
/** Whether a buffered group in `[start, end)` that `delivered` lacks still waits to be read. */
hasUnreadGroup: (subscriber: Subscriber, start: number, end: number | undefined, delivered: Delivered) => boolean;
/**
* Whether a subscriber's track ended and it holds nothing left to read: no datagram within its
* cursor, and no group in `[start, end)` that `delivered` lacks.
*/
spent: (subscriber: Subscriber, start: number, end: number | undefined, delivered: Delivered) => boolean;
/** How many runs of handed-out groups a subscriber remembers: one per gap, plus the floor. Tests only. */
deliveredRuns: (subscriber: Subscriber) => number;
/** Forget the gaps in another reader's `delivered` below each group past this subscriber's budget. */
Expand Down Expand Up @@ -642,6 +647,9 @@ export const hooks: {
hasUnreadGroup: () => {
throw new Error("track.ts not loaded");
},
spent: () => {
throw new Error("track.ts not loaded");
},
staleAt: () => {
throw new Error("track.ts not loaded");
},
Expand Down
Loading
Loading