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
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?
async function main () {
const blob = new Blob([
new Uint8Array([
58, 162, 101, 114, 111, 111, 116, 115, 129, 216, 42,
88, 37, 0, 1, 85, 18, 32, 95, 102, 197, 19,
218, 30, 103, 78, 133, 139, 57, 105, 28, 11, 0,
246, 124, 167, 41, 140, 239, 220, 248, 168, 136, 35,
196, 72, 236, 184, 232, 89, 103, 118, 101, 114, 115,
105, 111, 110, 1
]),
new Uint8Array([ 68 ]),
new Uint8Array([
1, 85, 18, 32, 95, 102, 197, 19,
218, 30, 103, 78, 133, 139, 57, 105,
28, 11, 0, 246, 124, 167, 41, 140,
239, 220, 248, 168, 136, 35, 196, 72,
236, 184, 232, 89
]),
new Uint8Array([
90, 189, 174, 145, 144, 134, 214,
117, 47, 251, 231, 254, 29, 238,
0, 29, 212, 201, 123, 107, 95,
130, 24, 168, 207, 139, 134, 177,
187, 88, 167, 36
])
])
await blob.stream().pipeTo(new WritableStream({
write (chunk) {
console.log(chunk)
}
}))
}
main().then(() => console.log('done')).catch(console.error)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?
Uint8Array(59) [
58, 162, 101, 114, 111, 111, 116, 115, 129, 216, 42,
88, 37, 0, 1, 85, 18, 32, 95, 102, 197, 19,
218, 30, 103, 78, 133, 139, 57, 105, 28, 11, 0,
246, 124, 167, 41, 140, 239, 220, 248, 168, 136, 35,
196, 72, 236, 184, 232, 89, 103, 118, 101, 114, 115,
105, 111, 110, 1
]
Uint8Array(1) [ 68 ]i.e. missing 2 chunks and no "done"
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
Activity
bellbind commentedon Jul 25, 2023
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:
$ 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:
From the blame list of lib/internal/blob.js, the bug spawned by the change of 8cc1438 .
This issue may be same as #48668
fix lib/internal/blob.js for nodejs#48668 nodejs#48916
lib: fix lib/internal/blob.js Blob.stream() for nodejs#48668 nodejs#4β¦
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
fix: revert workaround for bug in nodejs 20.5 (#905)
lib: fix to add resolve() before return at Blob.stream()'s source.pull()
fix: revert workaround for bug in nodejs 20.5 (#905)