Skip to content

Fix cancelPromise in ReadableStreamTee being resolved twice (again)#1118

Merged
domenic merged 2 commits into
whatwg:mainfrom
MattiasBuelens:fix-tee-cancel-double-resolve-episode-two
Mar 31, 2021
Merged

Fix cancelPromise in ReadableStreamTee being resolved twice (again)#1118
domenic merged 2 commits into
whatwg:mainfrom
MattiasBuelens:fix-tee-cancel-double-resolve-episode-two

Conversation

@MattiasBuelens

@MattiasBuelens MattiasBuelens commented Mar 27, 2021

Copy link
Copy Markdown
Collaborator

I liked #1112 so much that I wanted to fix it twice! 😛

The following test case throws an AssertionError:

const rs = new ReadableStream({});

const [branch1, branch2] = rs.tee();

const cancel1 = branch1.cancel();
await flushAsyncEvents();
const cancel2 = branch2.cancel();

await Promise.all([cancel1, cancel2]);

This time, the error comes from this line:

promise_test: Unhandled rejection with value: object "AssertionError: false == true"
Error
    at AssertionError.get_stack (http://127.0.0.1:51551/resources/testharness.js:3553:21)
    at new AssertionError (http://127.0.0.1:51551/resources/testharness.js:3546:27)
    at assert (http://127.0.0.1:51551/resources/testharness.js:3539:19)
    at Test.<anonymous> (http://127.0.0.1:51551/resources/testharness.js:618:29)
    at Test.step (http://127.0.0.1:51551/resources/testharness.js:1977:25)
    at http://127.0.0.1:51551/resources/testharness.js:2002:35

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

@MattiasBuelens

Copy link
Copy Markdown
Collaborator Author

I think this should be the last one. We now have checks in all places where we resolve cancelPromise, and each of those is covered by at least one test. 😅

@MattiasBuelens
MattiasBuelens force-pushed the fix-tee-cancel-double-resolve-episode-two branch from ef6234b to e1c422b Compare March 27, 2021 00:32
domenic pushed a commit to web-platform-tests/wpt that referenced this pull request Mar 29, 2021

@domenic domenic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and very nice find. It seems like the assertions are pretty worthwhile after all if they lead to discovering real browser bugs. Can you file Firefox and Safari bugs, and roll WPT again?

@ricea

ricea commented Mar 29, 2021

Copy link
Copy Markdown
Collaborator

lgtm. You can say Chrome is interested.

@evilpie

evilpie commented Mar 30, 2021

Copy link
Copy Markdown
Member

This is on my radar. I am going to fix it after the test landed in the mozilla repository.

@MattiasBuelens
MattiasBuelens force-pushed the fix-tee-cancel-double-resolve-episode-two branch from e1c422b to 2bfb5f3 Compare March 30, 2021 22:01
@MattiasBuelens

Copy link
Copy Markdown
Collaborator Author

WPT updated. Should be ready to merge.

Can I assume that @ricea and @evilpie will open the Chromium and Firefox issues respectively? (When you do, comment with the issue link here so we can keep track.) Then I'll take care of opening the Safari issue. 🙂

@MattiasBuelens

Copy link
Copy Markdown
Collaborator Author

Hmm, make deploy failed on CI. Not sure why.

Gonna try to rebase on main and see if that helps. 😛

@MattiasBuelens
MattiasBuelens force-pushed the fix-tee-cancel-double-resolve-episode-two branch from bfa2036 to 9a5bcc7 Compare March 30, 2021 23:18
@ricea

ricea commented Mar 30, 2021

Copy link
Copy Markdown
Collaborator

I filed https://bugs.chromium.org/p/chromium/issues/detail?id=1194266.

@domenic
domenic merged commit 6762cdb into whatwg:main Mar 31, 2021
@MattiasBuelens
MattiasBuelens deleted the fix-tee-cancel-double-resolve-episode-two branch March 31, 2021 21:47
@evilpie

evilpie commented Apr 1, 2021

Copy link
Copy Markdown
Member

https://bugzilla.mozilla.org/show_bug.cgi?id=1702636

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 2, 2021
…'d branches in sequence with delay, a=testonly

Automatic update from web-platform-tests
Streams: more tee() cancelation tests

For whatwg/streams#1118.
--

wpt-commits: 1bdb43faa7434d36645ab5c64e754b5caefbc9d2
wpt-pr: 28266
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 2, 2021
…'d branches in sequence with delay, a=testonly

Automatic update from web-platform-tests
Streams: more tee() cancelation tests

For whatwg/streams#1118.
--

wpt-commits: 1bdb43faa7434d36645ab5c64e754b5caefbc9d2
wpt-pr: 28266
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 7, 2021
…'d branches in sequence with delay, a=testonly

Automatic update from web-platform-tests
Streams: more tee() cancelation tests

For whatwg/streams#1118.
--

wpt-commits: 1bdb43faa7434d36645ab5c64e754b5caefbc9d2
wpt-pr: 28266
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 8, 2021
…'d branches in sequence with delay, a=testonly

Automatic update from web-platform-tests
Streams: more tee() cancelation tests

For whatwg/streams#1118.
--

wpt-commits: 1bdb43faa7434d36645ab5c64e754b5caefbc9d2
wpt-pr: 28266
aarongable pushed a commit to chromium/chromium that referenced this pull request Apr 1, 2022
This change addresses the issue of resolving an already resolved
|cancelPromise| in ReadableStreamTee, by checking if both branches have
already been canceled. If that is the case, we will have already
resolved |cancelPromise| and don't need to resolve it again.

The corresponding specification changes are:
- whatwg/streams#1112
- whatwg/streams#1118

Bug: 1194266
Change-Id: Iccd6917c1ed98ea5677ba71e050a5f07a5b2b6ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3565500
Reviewed-by: Adam Rice <[email protected]>
Commit-Queue: Nidhi Jaju <[email protected]>
Cr-Commit-Position: refs/heads/main@{#987847}
jwidar pushed a commit to jwidar/LatencyZeroGithub that referenced this pull request Sep 16, 2025
…'d branches in sequence with delay, a=testonly

Automatic update from web-platform-tests
Streams: more tee() cancelation tests

For whatwg/streams#1118.
--

wpt-commits: 1bdb43faa7434d36645ab5c64e754b5caefbc9d2
wpt-pr: 28266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants