Replies: 1 comment
-
@gabrielschulhof can correct me if I'm wrong but I think what you say is correct. process.exit() is exit without cleanup and if asynchronous operations are not complete it won't be safe to tear down an env and run the cleanup hooks in general. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
relative context: vercel/next.js#35803 (comment)
There is a codebase I'm using
napi_add_env_cleanup_hook
to initiate teardown when a node.js process lifecycle completes. It was working as expected under normal circumstances, but it looks like it is not being called when process exits explitly: roughly,// working
// not working
Peeking process.exit() doc for its behavior, it looks like expected behavior
as it does not give any gaurantee to handling / flushing out remaining task in the queue.
napi_add_env_cleanup_hook
in a graceful way regardless of how process exits?I've managed to expose a new interface for explicit teardown and chaning it via
process.on('exit')
. It seems to work, but I hope if there's simplified way works automatically across all exits with automatic cleaning hook.Beta Was this translation helpful? Give feedback.
All reactions