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
fix: call node::Stop on exit #25430
fix: call node::Stop on exit #25430
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll also want to invoke this in ELECTRON_RUN_AS_NODE
(e.g in node_main
) @nornagon
with regard to why we weren't previously calling it, @zcbenz is correct, it wasn't introduced until v11 and was just an oversight. I'll try to spend some time thinking about a potential way to test this more directly 🤔
The node embedder teardown API certainly seems a lot more complex than it needs to be 🤔 |
Release Notes Persisted
|
I have automatically backported this PR to "10-x-y", please check out #25458 |
I have automatically backported this PR to "11-x-y", please check out #25459 |
It seems we encountered the same issue on 8.4.1. any hints to port this patch to 8.x.y branch ? |
Yeah, if this was added in Node 11 then we should probably backport to 8.x. |
/trop run backport-to 9-x-y 8-x-y |
The backport process for this PR has been manually initiated - |
/trop run backport-to 8-x-y |
I was unable to backport this PR to "9-x-y" cleanly; |
The backport process for this PR has been manually initiated - |
I was unable to backport this PR to "8-x-y" cleanly; |
* fix: call node::Stop on exit (#25430) * Update node_main.cc
When will this be release in 10.1.6 ? |
Description of Change
I believe this fixes #25267, the "illegal access" message we sometimes see at exit.
I don't have a test or a full root cause analysis for this yet, but what appears to be happening is this:
node::FreeEnvironment
fromElectronBrowserMainParts::PostMainMessageLoopRun
, it callsnode::CleanupHandles
.node::CleanupHandles
disallows JS execution, usingIsolate::DisallowJavascriptExecutionScope
.node::CleanupHandles
triggers a uv loop run, which triggersElectronBindings::OnCallNextTick
.ElectronBindings::OnCallNextTick
runs the microtask queue, which sometimes includes an entry into JS. (Not always, though. This is the bit I'm confused about: what are the conditions in which there's a pending JS microtask here?)This change causes
env->can_call_into_js()
to return false afternode::Stop()
is called, which meansInternalCallbackScope::Close()
won't run any JS, which avoids this error.The remaining questions in my mind are:
node::Stop()
before? Was it simply an oversight, or was it an intentional choice?CleanupHandles
end up invoking JS? What is putting a JS task in the microtask queue during exit?Checklist
npm test
passesRelease Notes
Notes: Fixed an issue that could cause a normally-exiting process to fail with an "illegal access" message and exit code 7.