-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial: remove forAuthorCode and use dictionaries for read() return value #1045
Conversation
This is better than I expected. This pretty closely reflects what we'll need to do to optimise pipeTo() anyway, so having the timing match up with the standard is useful. I need to think a bit more about the (chunkSteps, doneSteps, errorSteps) tuple. I think this is worth pursuing, and I'm in favour of it provided we can make it work. |
This now passes all tests. I inserted a manual microtask for teeing, which I think is reasonable. The tests were not able to detect any other instances of timing changes, and I believe that they're exhaustive. The potentially affected instances of ReadableStreamDefaultReaderRead are:
(ReadableStreamBYOBReaderRead only has public API callers, although in theory piping could use it too.) I'm happy to port this over to the spec text, once folks have had a chance to make any editorial suggestions. |
Looks good to me! 👍 I especially like the separation between Perhaps we could use a "struct" or a "tuple" in the spec text to represent all three steps, so we can thread them as a single argument through the various operations? Or would that make the reference implementation too different from the spec text? |
A struct or tuple seems very doable, although it's a tradeoff. It makes passing them through algorithms easier, but requires a bit more work to call them (e.g., it'd be something like "Perform readRequest.[[Steps]]'s done steps" instead of "Perofrm readRequest.[[doneSteps]]"). |
This might be a dumb question, but wouldn't |
Oh, sure, that's true. Then we'd need to manually copy the three items over from the (chunkSteps, doneSteps, errorSteps) tuple into the read request tuple, which would slightly decrease the benefit of keeping them together, but we're already doing that anyway with them as separate parameters. So I think it would indeed be a strict improvement. |
Hmmm... having read results available synchronously is a potential footgun. If code is written naively it can run into reentrancy issues. But since AFAIK Fetch is the only spec that actually reads from a stream, the potential damage is limited. lgtm, please write spec text when you are ready. |
6f6a064
to
d01fffd
Compare
Alright, this is good to go. I should probably write a Fetch patch too and hold off on merging this until that is ready. (In general I want to work on making streams better for other specs to interface with, so that'll potentially be a bit of wasted work, but we'll see.) |
Fixes #780. Fixes #976. Follows whatwg/streams#1045.
Although the long-term relationship isn't obvious, whatwg/fetch#1044 wants this at least for now
Fixes #780. Fixes #976. Follows whatwg/streams#1045.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Very nice.
Fixes #780. Fixes #976. Follows whatwg/streams#1045.
This is a start at tackling #1036. The intention is to have no normative behavior changes. However, note that I have not introduced artificial microtasks, so there are probably be some normative timing changes. If so then we should probably fix that, unless for some reason we think this would be an improvement.
Right now I've just done the reference implementation to give people an idea of what it looks like. If we can get all the tests passing and the shape of the solution hammered out, then I can port it to the spec text.
There are two kinds of failing tests currently:
readable-streams/tee.any.html
: "ReadableStream teeing: errors in the source should propagate to both branches" fails.readable-byte-streams/general.any.html
craps out due to a timeout in "ReadableStream with byte source: A stream must be errored if close()-d before fulfilling read(view) with Uint16Array", and then the harness doesn't continue with the rest of the tests, so there are unknown failures there.Both of these could be due to something stupid I missed, or due to the timing changes. I'll investigate tomorrow.
In the meantime, I'd appreciate thoughts on how this looks to folks, and whether it's a promising direction. For example, does the
(chunkSteps, doneSteps, errorSteps)
tuple seem like the right way to go? For byte streams especially, I had to thread them through more places than I'd hoped; is that OK, or does it make this less worth pursuing?Preview | Diff