Browse Source

fix: destroy node platform after destroying wrappers (#22537)

Co-authored-by: Cheng Zhao <[email protected]>
Cheng Zhao 5 years ago
parent
commit
20c5a3b9e1
1 changed files with 5 additions and 3 deletions
  1. 5 3
      shell/browser/electron_browser_main_parts.cc

+ 5 - 3
shell/browser/electron_browser_main_parts.cc

@@ -522,9 +522,6 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
   ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler);
 #endif
 
-  node_debugger_->Stop();
-  js_env_->OnMessageLoopDestroying();
-
 #if defined(OS_MACOSX)
   FreeAppDelegate();
 #endif
@@ -541,6 +538,11 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
     ++iter;
   }
 
+  // Destroy node platform after all destructors_ are executed, as they may
+  // invoke Node/V8 APIs inside them.
+  node_debugger_->Stop();
+  js_env_->OnMessageLoopDestroying();
+
   fake_browser_process_->PostMainMessageLoopRun();
 }