Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Fix chrome session restore promt in Windows (#606)
Browse files Browse the repository at this point in the history
* Trying to fix chrome crash message

* Shut down chrome more nicely

* Add comment back

* 'if' block had no effect
  • Loading branch information
aj-r authored and roblourens committed Mar 14, 2018
1 parent 907274f commit db839b7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,22 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
// Only kill Chrome if the 'disconnect' originated from vscode. If we previously terminated
// due to Chrome shutting down, or devtools taking over, don't kill Chrome.
if (coreUtils.getPlatform() === coreUtils.Platform.Windows && this._chromePID) {
// Run synchronously because this process may be killed before exec() would run
const taskkillCmd = `taskkill /F /T /PID ${this._chromePID}`;
let taskkillCmd = `taskkill /PID ${this._chromePID}`;
logger.log(`Killing Chrome process by pid: ${taskkillCmd}`);
try {
// Run synchronously because this process may be killed before exec() would run
execSync(taskkillCmd);
} catch (e) {
// Can fail if Chrome was already open, and the process with _chromePID is gone.
// Or if it already shut down for some reason.
}
// execSync above may succeed, but Chrome still might not shut down, for example if the web page promts the user about unsaved changes.
// In that case, we need to use /F to force shutdown, but we risk Chrome not shutting down correctly.
taskkillCmd = `taskkill /F /PID ${this._chromePID}`;
logger.log(`Killing Chrome process by pid (using force in case the first attempt failed): ${taskkillCmd}`);
try {
execSync(taskkillCmd);
} catch (e) {}
} else {
logger.log('Killing Chrome process');
this._chromeProc.kill('SIGINT');
Expand Down

0 comments on commit db839b7

Please sign in to comment.