Repository navigation
Do not throw from ReadableByteStreamControllerClose - #1388
shannonbooth wants to merge 2 commits into
Conversation
The "close a ReadableStream" algorithm for other specifications performs ! ReadableByteStreamControllerClose(), but that throws, after erroring the stream, when the first pending pull-into descriptor holds only part of an element. Fetch reaches this when a network body ends with a BYOB read pending, e.g., a 1-byte body read into a Uint16Array.
|
Huh, interestingly safari on my machine actually hits this issue |
Though the WPT CI seems happy, so it must have been fixed in Webkit at some point recently |
|
I always found this to be a weird part of the specification... Is it really the byte source's fault that the BYOB reader is trying to do a multi-byte I'm wondering if we should just get rid of the "throw e" in step 4.2.3, and let the byte source tear down "normally" while only the reader gets the error. Edit: I'm moving this discussion back to #1387, since it would require quite a different PR. |
|
I think there might be an option there! I'm looking at that. I'm also realising that I might not be fully fixing the problem with the current revision and am looking a little into interactions with tee |
Rather than handling the abrupt completion in "close a ReadableStream", make ReadableByteStreamControllerClose() return after erroring the stream, so that every caller performing it with ! is correct, including ReadableByteStreamTee(). controller.close() throws the stream's stored error instead, so its behavior is unchanged. ReadableByteStreamTee() also skips responding to the BYOB branch when closing it errored it, as erroring cleared its pending pull-into descriptors.
|
@MattiasBuelens my previous version indeed had problems. Turns out it causes a crash in the new tests I pushed to web-platform-tests/wpt#64154. Also turns out that chrome is crashing on those tests (there looks to be an open issue for it). I think this version is a minimal fix perhaps? |
|
Yes, your fix looks pretty similar to what my LLM landed on. 😅 MattiasBuelens@45f3135 We could land this first to fix the problem while preserving the user-visible behavior of |
Put that commit message as MR description as I think it's more clear than my original. From some further LLM review of these changes, that found a different specification assertion failure, will split out an issue for that (edit: #1390) |
ReadableByteStreamControllerClose already errors the stream when the first
pending pull-into descriptor holds only part of an element, so throwing
afterwards only matters to controller.close(). Move the throw there, so
the internal callers that use ! ("close a ReadableStream" and the
ReadableByteStreamTee close steps) see the stream become errored instead
of an abrupt completion.
Also skip RespondWithNewView on the BYOB branch in ReadableByteStreamTee
when closing it has errored it and cleared its pending pull-intos.
Fixes: #1387
*
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff