Skip to content
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

Does pipeTo() wait for writes to complete even when there are no writes? #945

Open
ricea opened this issue Jul 24, 2018 · 3 comments
Open
Labels
clarification Standard could be clearer piping

Comments

@ricea
Copy link
Collaborator

ricea commented Jul 24, 2018

https://streams.spec.whatwg.org/commit-snapshots/51227372cc84846bdcf68312724c4cac6a4b9e58/#rs-pipeTo-shutdown-with-action

Wait until every chunk that has been read has been written

I think it's ambiguous whether this waits when no chunks have been read or not. This is visible because the behaviour of a pipeTo() that starts when one or both sides is closed or errored is tightly specified, and because waiting is detectable via microtask execution.

@domenic
Copy link
Member

domenic commented Jul 31, 2018

Hmm. I'm not sure I'm happy that we prescribe a particular number of microtasks in such cases, especially since we're semi-intentionally using ambiguous wording like "wait".

Maybe we could make my above thoughts explicit, by inserting something like

Optionally, wait an additional user-agent determined amount of time. NOTE: this is intended to help avoid tightly specifying the number of microtasks in zero-chunk or immediately-errored cases.

WDYT?

@domenic domenic added piping clarification Standard could be clearer labels Jul 31, 2018
@ricea
Copy link
Collaborator Author

ricea commented Aug 3, 2018

web-platform-tests/wpt#12296 demonstrates one kind of timing sensitivity we have. Adding a Promise.resolve() to permit the promise returned by start() to settle changes the rejection returned by pipeTo(). I'm pretty sure that this behaviour is mandated by the standard.

I think probably implementations should be permitted to have either behavior in the "erroring" case.

Or maybe we want to force the initial check to always be asynchronous? That would make all currently compliant implementations non-conformant, which is bad. Also it's mildly inefficient.

Optionally, wait an additional user-agent determined amount of time. NOTE: this is intended to help avoid tightly specifying the number of microtasks in zero-chunk or immediately-errored cases.

I don't want to let them wait an arbitrary time. If it sometimes took 3 seconds for pipeTo() to do anything that would be very hard to work with. I want to say something like "Optionally, execute some pending tasks"

@domenic
Copy link
Member

domenic commented Aug 9, 2018

Hmm. Still having trouble deciding on the best approach here. Maybe it's simplest to just say that you're not allowed to wait, and nail things down that way? I.e. only wait if any writes have actually happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer piping
Development

No branches or pull requests

2 participants