Skip to content

Keep a byobRequest held across tee() working - #7478

Merged
jasnell merged 1 commit into
mainfrom
jasnell/ts-streams-held-byob-request-across-tee
Sep 24, 2026
Merged

jasnell merged 1 commit into
mainfrom
jasnell/ts-streams-held-byob-request-across-tee

Conversation

@jasnell

@jasnell jasnell commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

tee() and detach invalidated a cached byobRequest, so a source holding it across an await (a released read, then a fork) threw from respond(), erroring the stream and every branch. The spec leaves the request valid: the fork does not touch the controller's head pull-into.

The controller now takes over the sole cursor's released head at the fork. byobRequest is over it until respond(), respondWithNewView(), enqueue(), error(), cancel or a closed-state respond(0) retires it; a respond enqueues its bytes, old and new, for every cursor, which drop their own copies of the old ones.

C++ keeps the request working too but then breaks on the next enqueue() and drops the released read's bytes: readable-byte ledger #25. Behind the experimental typescript_implemented_streams flag.

Note: this refines a previous change in one of the recent fix batches to make the behavior more correct.

@jasnell
jasnell requested review from guybedford and npaun September 22, 2026 21:09
@jasnell
jasnell requested review from a team as code owners September 22, 2026 21:09
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

tee() and detach invalidated a cached byobRequest, so a source holding
it across an await (a released read, then a fork) threw from respond(),
erroring the stream and every branch. The spec leaves the request valid:
the fork does not touch the controller's head pull-into.

The controller now takes over the sole cursor's released head at the
fork. byobRequest is over it until respond(), respondWithNewView(),
enqueue(), error(), cancel or a closed-state respond(0) retires it; a
respond enqueues its bytes, old and new, for every cursor, which drop
their own copies of the old ones.

C++ keeps the request working too but then breaks on the next enqueue()
and drops the released read's bytes: readable-byte ledger #25. Behind
the experimental typescript_implemented_streams flag.
@jasnell
jasnell force-pushed the jasnell/ts-streams-held-byob-request-across-tee branch from 38e6e95 to 90c842c Compare September 24, 2026 03:09
@jasnell
jasnell merged commit b1c639d into main Sep 24, 2026
22 checks passed
@jasnell
jasnell deleted the jasnell/ts-streams-held-byob-request-across-tee branch September 24, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants