Repository navigation
Blob.stream().pipeTo() never resolves #48916
Copy link
Copy link
Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
Description
Activity
This code is OK on node-v20.3.1-darwin-arm64.tar.gz, and failed on node-v20.4.0-darwin-arm64.tar.gz
other case:
// blob.mjs import {describe, it, before, after} from "node:test"; import {strict as assert} from "node:assert"; describe("blob", async () => { it("stream", async () => { const bufs = []; const blob = new Blob(["A", "B", "C"]); await blob.stream().pipeTo(new WritableStream({ write(chunk) { bufs.push(new TextDecoder().decode(chunk)); } })); assert.equal(bufs.join(""), "ABC"); //assert.deepEqual(bufs, ["A", "B", "C"]); //node-20.3.1 //assert.deepEqual(bufs, ["ABC"]); //chrome and firefox }); });
$ asdf global nodejs 20.3.1 $ node blob.mjs ▶ blob ✔ stream (6.642917ms) ▶ blob (7.957ms) ℹ tests 1 ℹ suites 1 ℹ pass 1 ℹ fail 0 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 0.057125
$ asdf global nodejs 20.4.0 $ node blob.mjs ▶ blob ✖ stream (6.048208ms) 'Promise resolution is still pending but the event loop has already resolved' ▶ blob (6.810833ms) ℹ tests 1 ℹ suites 1 ℹ pass 0 ℹ fail 0 ℹ cancelled 1 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 1.912083 ✖ failing tests: ✖ stream (6.048208ms) 'Promise resolution is still pending but the event loop has already resolved' ✖ blob (6.810833ms) 'Promise resolution is still pending but the event loop has already resolved'
I encountered the problem when using Blob with helia:
import {describe, it} from "node:test"; import {strict as assert} from "node:assert"; import {createHelia} from "helia"; import {unixfs} from "@helia/unixfs"; describe("helia", async () => { it("unixfs.addByteStream", async () => { const node = await createHelia(); const nodefs = unixfs(node); const blob = new Blob(["Hello World!"], {type: "text/plain"}); const cid = await nodefs.addByteStream(blob.stream()); //never finished from nodejs>=20.4.0 console.log(cid); await node.stop(); }); });
From the blame list of lib/internal/blob.js, the bug spawned by the change of 8cc1438 .
This issue may be same as #48668
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Jul 26, 2023 - added a commit that references this issue
on Aug 12, 2023 - added a commit that references this issue
on Sep 6, 2023 - added a commit that references this issue
on Feb 18, 2024 - added a commit that references this issue
on Sep 29, 2025
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
Version
20.5.0
Platform
Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Every run.
What is the expected behavior? Why is that the expected behavior?
Expected to see all the chunks printed to console and then "done".
What do you see instead?
i.e. missing 2 chunks and no "done"
Additional information
No response