fix(core): fix APIs not to be affected by Promise.prototype.then modification (#16326)

This commit is contained in:
Kenta Moriuchi 2022-10-29 18:25:23 +09:00 committed by GitHub
parent edaceecec7
commit 59ac110edd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 145 additions and 42 deletions

View file

@ -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