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

Fix pipeTo() tests #106

Merged
merged 8 commits into from
Nov 19, 2021
Merged

Fix pipeTo() tests #106

merged 8 commits into from
Nov 19, 2021

Conversation

MattiasBuelens
Copy link
Owner

In #99, I disabled a few WPT tests for pipeTo() because the public reader/writer API isn't powerful enough to implement all of the spec details. For example, it's not possible to synchronously detect if the stream starts out closed or errored using only reader.closed and writer.closed, but the WPT tests do demand this precision.

With this PR, we compromise. We still use the public API as much as possible, for maximum compatibility. However, if the given streams are created by the polyfill itself, then we use some internal fields and abstract ops where no other alternative is available. Currently, that's the case for:

  • Detecting whether the stream starts out closed or errored before starting the pipe.
  • Detecting whether writer.close() was called before pipeTo(), i.e. for WritableStreamCloseQueuedOrInFlight().

(We still have the cheating test though. I still think the test is wrong, so I'm not going to try to make the polyfill pass it. 😛)

* Initialize currentRead and currentWrite to undefined, so we can skip awaiting them if still unset.
* Wait for all reads to finish before calling writer.close().
  Previously, this happened implicitly because the final read would still change currentWrite
  after reader.closed has resolved. This is quite brittle, since it relies on timing of promise reactions.
@MattiasBuelens MattiasBuelens added this to the v4.0.0 milestone Nov 17, 2021
@MattiasBuelens MattiasBuelens self-assigned this Nov 17, 2021
@MattiasBuelens MattiasBuelens merged commit 354aabb into next Nov 19, 2021
@MattiasBuelens MattiasBuelens deleted the fix-pipe-tests branch November 19, 2021 17:22
MattiasBuelens added a commit that referenced this pull request Nov 9, 2022
This reverts commit 354aabb, reversing
changes made to 4f231a4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant