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

Emit a warning if process exits with unsettled modules? #39665

Open
targos opened this issue Aug 5, 2021 · 2 comments
Open

Emit a warning if process exits with unsettled modules? #39665

targos opened this issue Aug 5, 2021 · 2 comments
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. esm Issues and PRs related to the ECMAScript Modules implementation.

Comments

@targos
Copy link
Member

targos commented Aug 5, 2021

Here's a simple ES module with top-level await:

console.log('before');

await new Promise(() => {});

console.log('after');

Executing it only prints before and then exits with code 13.

I don't know where the exit code is set, but it seems that we actually detect that the promise representing the module's execution never settles.
Could we emit/print a warning when it happens? Ideally it could contain the path to the problematic module.

@targos targos added esm Issues and PRs related to the ECMAScript Modules implementation. errors Issues and PRs related to JavaScript errors originated in Node.js core. labels Aug 5, 2021
@RaisinTen
Copy link
Contributor

I'm pretty sure this is where the exit code is set:

process.exitCode = 13;

and it was introduced in #34640

@nickserv
Copy link

I was confused to notice a failing command when I switched shells, even though my Node program wasn't printing any errors. I had to do a few minutes of searching to understand what was going on. An error explaining how this can be fixed would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. esm Issues and PRs related to the ECMAScript Modules implementation.
Projects
None yet
Development

No branches or pull requests

3 participants