Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ext/file): resolve unresolved Promise in Blob.stream (denoland#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:https://github.com/denoland/deno/blob/6ba245fe2570b29e35a4fd296a196a58870b1e3c/ext/web/06_streams.js#L2026 which ends up calling `readIntoRequest.closeSteps(chunk);` in https://github.com/denoland/deno/blob/6ba245fe2570b29e35a4fd296a196a58870b1e3c/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 ```
- Loading branch information