fix: ensure we wait for the inspect to disconnect
This re-orders our node clean up so that we free the environment before the task runner is cleaned up as node uses the task runner during clean up. It also calls WaitForDisconnect() to ensure that inspector agents are notified that the context is going down.
This commit is contained in:
parent
60821c8ab0
commit
2132fdfa28
3 changed files with 10 additions and 4 deletions
|
@ -113,12 +113,15 @@ int NodeMain(int argc, char* argv[]) {
|
|||
|
||||
node_debugger.Stop();
|
||||
exit_code = node::EmitExit(env);
|
||||
env->set_can_call_into_js(false);
|
||||
node::RunAtExit(env);
|
||||
gin_env.platform()->DrainTasks(env->isolate());
|
||||
gin_env.platform()->CancelPendingDelayedTasks(env->isolate());
|
||||
gin_env.platform()->UnregisterIsolate(env->isolate());
|
||||
|
||||
v8::Isolate* isolate = env->isolate();
|
||||
node::FreeEnvironment(env);
|
||||
|
||||
gin_env.platform()->DrainTasks(isolate);
|
||||
gin_env.platform()->CancelPendingDelayedTasks(isolate);
|
||||
gin_env.platform()->UnregisterIsolate(isolate);
|
||||
}
|
||||
|
||||
// According to "src/gin/shell/gin_main.cc":
|
||||
|
|
|
@ -60,8 +60,10 @@ void NodeDebugger::Start() {
|
|||
|
||||
void NodeDebugger::Stop() {
|
||||
auto* inspector = env_->inspector_agent();
|
||||
if (inspector && inspector->IsListening())
|
||||
if (inspector && inspector->IsListening()) {
|
||||
inspector->WaitForDisconnect();
|
||||
inspector->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -390,6 +390,7 @@ describe('node feature', () => {
|
|||
const connection = new WebSocket(socketMatch[0])
|
||||
connection.onopen = () => {
|
||||
child.send('plz-quit')
|
||||
connection.close()
|
||||
done()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue