Missing close call on blob-get-stream causes the stream to never finish reading
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 118
- Forks
- 52
- Avg merge
- 9d 16h
- Merged PRs (30d)
- 1
Description
I believe blog get stream algorithm is missing a call to close that stream, which results in consumers of that readable stream never 'finishing' reading that stream.
For example, without a call to "close", from my reading 'done' will never get set to true for the following test:
let buffer = new ArrayBuffer(200);
let bytesReceived = 0;
let offset = 0;
let blob = new Blob(['Data to be read! 🦬']);
const stream = blob.stream();
const reader = stream.getReader({ mode: "byob" });
while (true) {
let result = await reader.read(new type(buffer, offset, buffer.byteLength - offset));
if (result.done) {
return;
}
buffer = result.value.buffer;
offset += result.value.byteLength;
bytesReceived += result.value.byteLength;
}
I think the fix should be just adding a close into the blob-get-stream algorithm after all bytes have been queued into the stream.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the File API blob-get-stream algorithm and the Streams specification's ReadableStream close algorithm. Reproduce the supplied Blob.stream() BYOB-reader example and verify that reading eventually returns done=true after all bytes are queued.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100