Skip to content

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

Description

@shannonbooth

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions