Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message for when there code evaluation is still pending and there are no pending async operations #43562

Closed
tom-sherman opened this issue Jun 24, 2022 · 6 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. feature request Issues that request new features to be added to Node.js.

Comments

@tom-sherman
Copy link

tom-sherman commented Jun 24, 2022

What is the problem this feature will solve?

Given the following program:

function main() {
  return new Promise(() => {});
}

await main();
console.log("hello");

Node.js exits the process immediately, with an error code of 13.

What is the feature you are proposing to solve the problem?

In addition to exiting with a non-zero code, show an error message.

This how deno works. Run the above program with deno run and you get the following error in the console:

error: Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promise.

What alternatives have you considered?

No response

@tom-sherman tom-sherman added the feature request Issues that request new features to be added to Node.js. label Jun 24, 2022
@tom-sherman tom-sherman changed the title Error when there code evaluation is still pending and there are no pending async operations Error message for when there code evaluation is still pending and there are no pending async operations Jun 24, 2022
@theanarkh
Copy link
Contributor

What is your Node.js version ? This code(put into test.mjs) works in v16.6.0 and v19.0.0-pre.

@tom-sherman
Copy link
Author

tom-sherman commented Jun 24, 2022

@theanarkh What do you mean by works? It's not supposed to work, it exits with an error code (13 - "Unfinished Top-Level Await") for me as documented here: https://nodejs.org/api/process.html#process_exit_codes

I opened this issue to suggest adding a friendly error message along with code to inform users why the program exited without having to google the error code. This is what deno does and it's quite nice.

@F3n67u
Copy link
Member

F3n67u commented Jun 24, 2022

Related issue: nodejs/promises-debugging#16, #43162

@F3n67u
Copy link
Member

F3n67u commented Jun 24, 2022

Duplicate of #42868

@F3n67u F3n67u marked this as a duplicate of #42868 Jun 24, 2022
@F3n67u F3n67u added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Jun 24, 2022
@theanarkh
Copy link
Contributor

@theanarkh What do you mean by works? It's not supposed to work, it exits with an error code (13 - "Unfinished Top-Level Await") for me as documented here: https://nodejs.org/api/process.html#process_exit_codes

I opened this issue to suggest adding a friendly error message along with code to inform users why the program exited without having to google the error code. This is what deno does and it's quite nice.

Sorry, i misunderstand it. i supposed what you mean is the process throw a Error and the code is 13.

@F3n67u
Copy link
Member

F3n67u commented Jun 25, 2022

Close it in favor of #42868

@F3n67u F3n67u closed this as completed Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

3 participants