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

lib: fix lib/internal/blob.js Blob.stream() for #48668 #48916 #48930

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/internal/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ class Blob {
queueMicrotask(() => {
if (c.desiredSize <= 0) {
// A manual backpressure check.
if (this.pendingPulls.length !== 0) {
// A case of waiting pull finished (= not yet canceled)
const pending = this.pendingPulls.shift();
pending.resolve();
}
return;
}
readNext();
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,19 @@ assert.throws(() => new Blob({}), {
reader.closed.then(common.mustCall());
})().then(common.mustCall());

(async () => {
const b = new Blob(['A', 'B', 'C']);
const stream = b.stream();
const chunks = [];
const decoder = new TextDecoder();
await stream.pipeTo(new WritableStream({
write(chunk) {
chunks.push(decoder.decode(chunk, { stream: true }));
}
}));
assert.strictEqual(chunks.join(''), 'ABC');
})().then(common.mustCall());

(async () => {
const b = new Blob(Array(10).fill('hello'));
const stream = b.stream();
Expand Down
Loading