-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
RFC process.on("shutdown") proposal #20804
Comments
There's an npm module that does this, right? Does it need to be in core? Would it be that much more helpful? |
there should definitely be a One True Way to tell if node is about to exit. (as its worth noting that receiving some of those events does not guarantee that node will exit in every situation) i think we should just streamline {things in c++ that make node stop running} to always go through a call to js if possible. |
My preference would be to make |
Changing the behavior of |
There are reasons why this isn’t the default for |
And maybe be confusing one unique event, because if I listen to the event |
is there an actionable on this issue? Is there any forward path justified / identified? |
It is technically possible to make this happen but, as Anna mentions, doing it properly significantly complicates signal handling; think signal masks, watchdog threads and asynchronous termination exceptions. We'd also need to carefully audit the code base for termination exception safety. I'm going to say the cost/benefit ratio currently isn't worth it and close this out. If someone volunteers, we can reconsider. And who knows, maybe it'll fall out as a side effect of worker-ifying core someday. |
See this popular question on so https://stackoverflow.com/q/14031763/3748498
By now there is no clean API to do cleanup when node.js exits, in order to catch all situation you need to do following:
This issue is a place for discussion how to fix it.
My proposal is
process.on("shutdown", cleanUp)
.The text was updated successfully, but these errors were encountered: