Repository navigation
Awaiting a Promise between creating a stream and consuming a stream causes Node to crash with code 13 #48668
Description
Activity
It's mentioned in the documentation on node's exit codes:
13Unfinished Top-Level Await:awaitwas used outside of a function
in the top-level code, but the passedPromisenever resolved.
- addedinvalidIssues and PRs that are invalid.Issues and PRs that are invalid.
on Jul 6, 2023 I expect the sample program to run to completion and print "Done", as it does in node v20.3.1
Sorry, I should have mentioned the old behavior was probably a bug. The new behavior is the expected behavior.
On second thought, I think this is indeed a bug, or at least an unintentional change in behavior introduced in f9c0d5a, cc @debadree25.
- addedstreamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.and removedinvalidIssues and PRs that are invalid.Issues and PRs that are invalid.
on Jul 6, 2023 hello!
hmm this does look like a bug so in my PR fixing hanging promises thing i am enqueing data during the microtask phase maybe thats causing some weird mixup in the event loop, I am investigating this! in the meanwhile do you think i should make a revert? in case this is breaking things?
I have an issue with blobs as well that started with Node
v20.4.0, but it's related toblobtostreamconversion andhttp2client transfer, which is leading to readable stream to never close, hanging connection forever ♾️
I will file a separate issue with reproduction example a bit later ⌚
But atm it's reproducible by simply running tests for this npm package 📦 https://www.npmjs.com/package/rekwestHere we go -> #48685
Similar bug with
fetch.const file = new Blob(['<svg></svg>'], { type: 'image/svg+xml' }); const url = URL.createObjectURL(file); const res = await fetch(url); const blob = await res.blob(); // does not resolve console.log(blob.size); // nothing loggedIt was working fine until
v20.3.1.There is also #48157 for blob related fixes.
Reacted by Yahor SiarheyenkaISTM, that #48232 fixed hanging promises, but causing hanging streams right now 🤔
And it might be missingpending.resolve()inside ofqueueMicrotask()🔬Reacted by Debadree ChatterjeeAnd it might be missing pending.resolve() inside of queueMicrotask() 🔬
But it does call promise resolve and reject inside the readNext fn
Nonetheless sorry for the delay I shall get to investigating it by tomorrow!
9 remaining items
- added a commit that references this issue
on Aug 12, 2023 - added a commit that references this issue
on Feb 18, 2024
Version
v20.4.0
Platform
Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64 arm Darwin
Subsystem
No response
What steps will reproduce the bug?
Run:
with
node. The process will exit with code13How often does it reproduce? Is there a required condition?
Always reproduces when the line
await Promise.resolve();is included (or awaiting any promise). If that line is commented out the program prints "Done"What is the expected behavior? Why is that the expected behavior?
I expect the sample program to run to completion and print "Done", as it does in
nodev20.3.1What do you see instead?
Node exiting with code 13:
Additional information
No response