Skip to content

Commit

Permalink
fix(ext/web/streams): enqueue to second branch before closing (denola…
Browse files Browse the repository at this point in the history
…nd#16269)

Co-authored-by: Luca Casonato <hello@lcas.dev>
  • Loading branch information
marcosc90 and lucacasonato authored Oct 14, 2022
1 parent 0d6dbc0 commit e6e2898
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 8 additions & 1 deletion ext/web/06_streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -2616,6 +2616,7 @@
assert(typeof cloneForBranch2 === "boolean");
const reader = acquireReadableStreamDefaultReader(stream);
let reading = false;
let readAgain = false;
let canceled1 = false;
let canceled2 = false;
/** @type {any} */
Expand All @@ -2634,14 +2635,15 @@

function pullAlgorithm() {
if (reading === true) {
readAgain = true;
return resolvePromiseWith(undefined);
}
reading = true;
/** @type {ReadRequest<R>} */
const readRequest = {
chunkSteps(value) {
queueMicrotask(() => {
reading = false;
readAgain = false;
const value1 = value;
const value2 = value;

Expand All @@ -2663,6 +2665,11 @@
value2,
);
}

reading = false;
if (readAgain === true) {
pullAlgorithm();
}
});
},
closeSteps() {
Expand Down
8 changes: 2 additions & 6 deletions tools/wpt/expectation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1336,12 +1336,8 @@
"patched-global.any.worker.html": true,
"reentrant-strategies.any.html": true,
"reentrant-strategies.any.worker.html": true,
"tee.any.html": [
"ReadableStream teeing: enqueue() and close() while both branches are pulling"
],
"tee.any.worker.html": [
"ReadableStream teeing: enqueue() and close() while both branches are pulling"
],
"tee.any.html": true,
"tee.any.worker.html": true,
"templated.any.html": true,
"templated.any.worker.html": true
},
Expand Down

0 comments on commit e6e2898

Please sign in to comment.