Skip to content

Commit d3394a0

Browse files
committed
Avoid Windows crashes when wmic is not available
Previously this code didn't actually listen for the result of the command at all, assuming incorrectly that it was a promise. Now it properly waits until the process closes, and watches for errors.
1 parent ad3c334 commit d3394a0

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/interceptors/fresh-firefox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class FreshFirefox implements Interceptor {
171171
if (process.platform === "win32") {
172172
// Firefox spawns a child process on Windows, and doesn't let us kill it at all.
173173
// To fix this, we kill all firefox instances that were started with this exact same URL.
174-
await windowsKill(`CommandLine Like '%\\\\firefox.exe%${initialUrl}'`);
174+
await windowsKill(`CommandLine Like '%\\\\firefox.exe%${initialUrl}'`).catch(console.log);
175175
} else {
176176
normalStop();
177177
}

src/util.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ export function getDeferred<T = void>(): Deferred<T> {
4747
}
4848

4949
export async function windowsKill(processMatcher: string) {
50-
await spawn('wmic', [
50+
await spawnToResult('wmic', [
5151
'Path', 'win32_process',
5252
'Where', processMatcher,
5353
'Call', 'Terminate'
54-
], {
55-
stdio: 'inherit'
56-
});
54+
], { }, true);
5755
}
5856

5957
// Spawn a command, and resolve with all output as strings when it terminates

0 commit comments

Comments
 (0)