From 59ac110edd1f376bed7fa6bbdbe2ee09c266bf74 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Sat, 29 Oct 2022 18:25:23 +0900 Subject: fix(core): fix APIs not to be affected by `Promise.prototype.then` modification (#16326) --- ext/fetch/26_fetch.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'ext/fetch/26_fetch.js') diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 5c824898d..e522079bf 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -529,14 +529,15 @@ // 2.6. // Rather than consuming the body as an ArrayBuffer, this passes each // chunk to the feed as soon as it's available. - (async () => { - const reader = res.body.getReader(); - while (true) { - const { value: chunk, done } = await reader.read(); - if (done) break; - ops.op_wasm_streaming_feed(rid, chunk); - } - })().then( + PromisePrototypeThen( + (async () => { + const reader = res.body.getReader(); + while (true) { + const { value: chunk, done } = await reader.read(); + if (done) break; + ops.op_wasm_streaming_feed(rid, chunk); + } + })(), // 2.7 () => core.close(rid), // 2.8 -- cgit v1.2.3