-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Ability to shutdown Node in-flight #19365
Comments
FYI @nodejs/delivery-channels |
@yhwang FYI as this is likely one of the use cases we'd want to include in our extended testing for the shared library support. |
I have written code for Ayo that does basically exactly this. I’ll try to port it over, especially since I’ve been meaning to do that anyway. |
@addaleax great to hear :) |
Opened #19377 with most of those commits, would be cool if those who are interested could take a look. |
One of the scenario that I tried to handle before is canceling the long-running javascript execution. And it's a tough case because of the resource clean up. For using node.js as shared lib, the mechanism that we provide to shutdown node may also need to handle this case. |
Looks like #19377 landed, @gireeshpunathil can you confirm we have what is needed for your original request. |
TIL
|
I think it’s not quite enough. We basically still want something that exposes I have something similar in my upcoming Workers PR, so I can try to make this happen. It might also make sense to put this in a larger picture and ask what other sensible exiting modes Node.js could use. Rather than introducing a new functions, we maybe want something like this? (API bikeshedding encouraged)
|
Btw, the big advantage of switching to the The downside is that that might not play well with addons which don’t expect error handling for execution terminations. |
|
+1 . We do need a C++ API to shutdown the Node.js runtime. For now, the And for the |
This commit introduces a `node::Stop()` API. An identified use case for embedders is their ability to tear down Node while it is still running (event loop contain pending events) Here the assumptions are that (i) embedders do not wish to resort to JS routines to initiate shutdown (ii) embedders have the Environment handle handy. (iii) embedders stop Node through a second thread. Fixes: nodejs#19365 Refs: nodejs/user-feedback#51 PR-URL: nodejs#21283 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com>
This commit introduces a `node::Stop()` API. An identified use case for embedders is their ability to tear down Node while it is still running (event loop contain pending events) Here the assumptions are that (i) embedders do not wish to resort to JS routines to initiate shutdown (ii) embedders have the Environment handle handy. (iii) embedders stop Node through a second thread. Fixes: nodejs#19365 Refs: nodejs/user-feedback#51 PR-URL: nodejs#21283 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com>
This commit introduces a `node::Stop()` API. An identified use case for embedders is their ability to tear down Node while it is still running (event loop contain pending events) Here the assumptions are that (i) embedders do not wish to resort to JS routines to initiate shutdown (ii) embedders have the Environment handle handy. (iii) embedders stop Node through a second thread. Fixes: #19365 Refs: nodejs/user-feedback#51 PR-URL: #21283 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com>
Scope: C++ applications that embed node as a shared library
Issue: Node's life cycle is designed around the event loop method uv_run that assumes exit only when the last handle is drained from the loop, while the embedder may have a larger life cycle in which node workload may be a small subset. For example, the embedder may want to recycle node in response to a shift in workload / configuration, even while the loop is filled with active handles. Current Node / libuv design does not provide such an on-demand exit route.
Proposal: Define a top level API (such as
quiesce
) that gracefully shuts down the loop and returns from node::Start().The text was updated successfully, but these errors were encountered: