From 4e1f2e2eb2c2473f7ceafabeea31d78a642b0b36 Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Fri, 16 Mar 2018 02:40:24 +0200 Subject: [PATCH] fix(Launcher): killing a process can throw (#2102) In case chrome process was terminated manually, killing the process might throw 'no process with such pid' exception. --- lib/Launcher.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Launcher.js b/lib/Launcher.js index a8bb9e37..1d39ff79 100644 --- a/lib/Launcher.js +++ b/lib/Launcher.js @@ -178,10 +178,14 @@ class Launcher { helper.removeEventListeners(listeners); if (chromeProcess.pid && !chromeProcess.killed && !chromeClosed) { // Force kill chrome. - if (process.platform === 'win32') - childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`); - else - process.kill(-chromeProcess.pid, 'SIGKILL'); + try { + if (process.platform === 'win32') + childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`); + else + process.kill(-chromeProcess.pid, 'SIGKILL'); + } catch (e) { + // the process might have already stopped + } } // Attempt to remove temporary profile directory to avoid littering. try {