From e6e28981909f220ff0b98a13c692c0203eaf6035 Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Fri, 14 Oct 2022 11:51:39 +0200 Subject: fix(ext/web/streams): enqueue to second branch before closing (#16269) Co-authored-by: Luca Casonato --- ext/web/06_streams.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 361e5e055..c783b9518 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -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} */ @@ -2634,6 +2635,7 @@ function pullAlgorithm() { if (reading === true) { + readAgain = true; return resolvePromiseWith(undefined); } reading = true; @@ -2641,7 +2643,7 @@ const readRequest = { chunkSteps(value) { queueMicrotask(() => { - reading = false; + readAgain = false; const value1 = value; const value2 = value; @@ -2663,6 +2665,11 @@ value2, ); } + + reading = false; + if (readAgain === true) { + pullAlgorithm(); + } }); }, closeSteps() { -- cgit v1.2.3