Skip to content
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

Electron is not propely killed when relaunching #2

Open
maxerbox opened this issue Jan 3, 2021 · 1 comment
Open

Electron is not propely killed when relaunching #2

maxerbox opened this issue Jan 3, 2021 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@maxerbox
Copy link

maxerbox commented Jan 3, 2021

Node 12.
Electron 8.
Under electron-nuxt 1.6.0.
OS : Debian bulleyes.

When relaunching electron, due to editing a file in electron-nuxt, electron is not properly killed, leaving a blank window and a new window is created.

@michalzaq12 michalzaq12 added the help wanted Extra attention is needed label Mar 25, 2021
@zarkin404
Copy link

zarkin404 commented Nov 15, 2022

Use the patch-package to patch code:

filename: @xpda-dev+electron-launcher+0.3.0.patch

diff --git a/node_modules/@xpda-dev/electron-launcher/lib/ElectronLauncher.js b/node_modules/@xpda-dev/electron-launcher/lib/ElectronLauncher.js
index 941fb90..29e0c16 100644
--- a/node_modules/@xpda-dev/electron-launcher/lib/ElectronLauncher.js
+++ b/node_modules/@xpda-dev/electron-launcher/lib/ElectronLauncher.js
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
 const child_process_1 = require("child_process");
 const events_1 = require("events");
 const core_1 = require("@xpda-dev/core");
-const { killWithAllSubProcess } = core_1.utils;
+const { killProcess } = core_1.utils;
 class ElectronLauncher extends events_1.EventEmitter {
     constructor(options) {
         super();
@@ -27,7 +27,7 @@ class ElectronLauncher extends events_1.EventEmitter {
     launch() {
         return __awaiter(this, void 0, void 0, function* () {
             let args = [`--inspect=${this.inspectionPort}`, this.entryFile, '--auto-detect=false', '--no-proxy-server', ...this.electronOptions];
-            this.process = child_process_1.spawn(this.electronPath, args);
+            this.process = child_process_1.spawn(this.electronPath, args, { detached: false });
             this.pipe(this.logger);
             this.process.on('exit', code => {
                 if (code === this.relaunchCode)
@@ -54,7 +54,9 @@ class ElectronLauncher extends events_1.EventEmitter {
                 return;
             this.emit('relaunch');
             yield this.exit();
-            this.launch();
+            setTimeout(() => {
+                this.launch();
+            }, 500);
         });
     }
     exit() {
@@ -64,7 +66,7 @@ class ElectronLauncher extends events_1.EventEmitter {
             this.process.removeAllListeners('exit');
             this.process.stdout.end();
             this.process.stderr.end();
-            yield killWithAllSubProcess(this.pid, this.logger.error.bind(this.logger));
+            yield killProcess(this.pid, this.logger.error.bind(this.logger));
             this.process = null;
         });
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants