```js
await (async () => {
const reader = new Response("HELLO").body.getReader({ mode: "byob" });
let done;
while (!done) {
console.log("not done");
// await new Promise(setTimeout)
done = (await reader.read(new Uint8Array(8))).done;
}
console.log("done");
})()
```
Somehow this only emits a single "not done" message and never ends, but it works when adding a setTimeout before the next read call.
Needs to be investigated.
Bug 1809673 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
```js
await (async () => {
const reader = new Response("HELLO").body.getReader({ mode: "byob" });
let done;
while (!done) {
// await new Promise(setTimeout)
const result = await reader.read(new Uint8Array(8));
done = result.done;
console.log(result);
}
})()
```
Somehow this only emits a single "not done" message and never ends, but it works when adding a setTimeout before the next read call.
Needs to be investigated.
```js
await (async () => {
const reader = new Response("HELLO").body.getReader({ mode: "byob" });
let done;
while (!done) {
// await new Promise(setTimeout)
const result = await reader.read(new Uint8Array(2));
done = result.done;
console.log(result);
}
})()
```
Somehow this only emits `done: false` but never emits `done: true`, but it works when adding a setTimeout before the next read call.
Needs to be investigated.
```js
await (async () => {
const reader = new Response("HELLO").body.getReader({ mode: "byob" });
let done;
while (!done) {
// await new Promise(setTimeout)
const result = await reader.read(new Uint8Array(2));
done = result.done;
console.log(result);
}
})()
```
Without setTimeout: 3 chunks "HE", "LL", "O" are read but then it stalls
With setTimeout: 1 chunk "HE" is read and then it ends, losing everything else.
Needs to be investigated.