1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/ext
Marcos Casagrande 5311f69bbb
fix(ext/file): resolve unresolved Promise in Blob.stream (#20039)
This PR fixes some crashing WPT tests due to an unresolved promise.

---
This could be a [stream spec](https://streams.spec.whatwg.org) bug

When `controller.close` is called on a byob stream, there's no cleanup
of pending `readIntoRequests`. The only cleanup of pending
`readIntoRequests` happen when `.byobRequest.respond(0)` is called, it
happens
here:6ba245fe25/ext/web/06_streams.js (L2026)
which ends up calling `readIntoRequest.closeSteps(chunk);` in
6ba245fe25/ext/web/06_streams.js (L2070)



To reproduce:

```js
async function byobRead() {
  const input = [new Uint8Array([8, 241, 48, 123, 151])];
  const stream = new ReadableStream({
    type: "bytes",
    async pull(controller) {
      if(input.length === 0) {
        controller.close();
        // controller.byobRequest.respond(0); // uncomment for fix 
        return 
      }
      controller.enqueue(input.shift())
    },
  });

  const reader = stream.getReader({ mode: 'byob' });
  const r1 = await reader.read(new Uint8Array(64));
  console.log(r1);
  const r2 = await reader.read(new Uint8Array(64));
  console.log(r2);
}

await byobRead();
```

Running the script triggers:
```
error: Top-level await promise never resolved
```
2023-08-04 13:57:54 +02:00
..
broadcast_channel 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
cache 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
console 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
crypto 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
fetch refactor(ext/fetch): refactor fetch to use new write_error method (#20029) 2023-08-03 14:27:25 -06:00
ffi 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
fs 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
http refactor: rewrite http_next ops to use op2 macro (#19934) 2023-08-03 20:36:32 +00:00
io 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
kv 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
napi 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
net 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
node refactor(ext/fetch): refactor fetch to use new write_error method (#20029) 2023-08-03 14:27:25 -06:00
tls 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
url 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
web fix(ext/file): resolve unresolved Promise in Blob.stream (#20039) 2023-08-04 13:57:54 +02:00
webidl 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
websocket 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00
webstorage 1.36.0 (#20036) 2023-08-03 18:26:25 +02:00