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

Node.js process does not exit when unhandled promise rejection occured #2195

Open
MengLi619 opened this issue Feb 6, 2025 · 1 comment
Open

Comments

@MengLi619
Copy link

Environment

  • Platform: Azure AKS
  • Docker Version: Unknown
  • Node.js Version: 18.19.0
  • Image Tag: node:18.19.0-alpine3.17

Expected Behavior

Node.js process should exit when unhandled promise rejection occurs

Current Behavior

Node.js process does not exit when unhandled promise rejection occurs

Possible Solution

Node.js process should exit because it's the default behavior after node.js 15, we depend on this behavior to restart and retry to finish the application startup process.

Steps to Reproduce

During the startup process, after an unhandled rejection is thrown, the node.js process does not exit.

Additional Information

@LaurentGoderre
Copy link
Member

I'm not getting this behavior.

% docker run --rm node:18.19.0-alpine3.17 -e 'Promise.reject("test")'
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "test".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.19.0
% echo $?                                                            
1

Perhaps this has to do with how your container is run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants