Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Process exits with unresolved promises #16

@BridgeAR

Description

@BridgeAR

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 running unresolved (likely a bad idea)
  • provide a warning on process exit about still running unresolved promises
  • exit with a non zero exit code in case promises are running unresolved
  • 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions