This repository was archived by the owner on Aug 7, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Process exits with unresolved promisesΒ #16
Copy link
Copy link
Open
Description
A lot of users struggle understanding why a Node.js process exits while a promise is still running not yet resolved (see e.g., nodejs/node#22088).
This is by design but the question is if it's really the best for most users. It definitely complicates debugging some cases.
I wonder if it makes sense to try to improve the situation for users by e.g., adding an opt-in to either
- keep the process running if promises are
still runningunresolved (likely a bad idea) - provide a warning on process exit about
still runningunresolved promises - exit with a non zero exit code in case promises are
runningunresolved - tbd
Adding such an opt-in feature would likely help debugging never resolving promises and stream based promises where the stream does not receive any data.
Example:
// Never resolves
(async function fn() {
await new Promise((resolve) => {});
console.log('Will not be reached');
})();Stream based example: nodejs/node#22088 (comment)
@nodejs/promises-debugging any opinions about this?
benjamingr, doesdev, tommyZZM, bipface, kirillgroshkov and 15 more
Metadata
Metadata
Assignees
Labels
No labels