Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing close call on blob-get-stream causes the stream to never finish reading #206

Open
shannonbooth opened this issue Dec 9, 2024 · 1 comment

Comments

@shannonbooth
Copy link

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.

@mkruisselbrink
Copy link
Collaborator

Ah yes, good catch. That sounds correct to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants