-
Notifications
You must be signed in to change notification settings - Fork 163
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
Make .ready fulfill-only? #245
Comments
Right. We can also do that at
How does this method look to you? An extra microtask is required to retrieve the exception. We can expose storedError for synchronous read but it seems overkilling. |
Yeah I guess it delays a microtask and the code looks a bit strange, but it's not too big of a deal.
I was able to modify it locally to just use
I agree. |
Re: WritableStream, I agree with you. It can also be fulfill-only.
Good point. We can say the same about |
Part of #245; see discussions in #243 (comment). Consumers should always either check the state property, or count on the fact that read() will throw when used on an errored stream.
Closes #245. Now .ready is just a signal that the stream has transitioned from "waiting" to any other state.
Part of #245; see discussions in #243 (comment). Consumers should always either check the state property, or count on the fact that read() will throw when used on an errored stream.
Closes #245. Now .ready is just a signal that the stream has transitioned from "waiting" to any other state.
Part of #245; see discussions in #243 (comment). Consumers should always either check the state property, or count on the fact that read() will throw when used on an errored stream.
Closes #245. Now .ready is just a signal that the stream has transitioned from "waiting" to any other state.
Continuing from #243 (comment):
The essential issue is that right now
rs.ready.then(f, r)
might callf
at a time when the stream is actually in an errored state, if the underlying source or sink causes an error between becoming readable andf
being called. So the story is something like "usually iff
is called it'll be readable or closed, and whenever it's errored it'll callr
with the error ... except not always."A few issues, none of them too serious:
Slightly more awkward for readable streams
I tried to change this and noticed it made one example a bit more awkward:
becomes something like
That is, it becomes mandatory to interact with the
.closed
promise now if you want access to the error object. Note that this doesn't work:Also note that the first version (i.e. with the current spec) isn't actually buggy, since if
pump
is called when the stream is errored it will just call.ready.then(pump, logTheError)
again.What do we do for writable streams?
Writable streams have basically the same problem. However we reject their
.ready
promise more often, i.e. when the stream begins closing, or is closed. Do we also want to eliminate those cases? My gut instinct is that yes, we do. In fact the current setup is not great.So what do you guys think, @tyoshino and @yutakahirano? Can we live with the change in consumer style? And are we OK making it fulfill-only for writable streams too? I think both are OK but wanted to discuss first.
The text was updated successfully, but these errors were encountered: