Skip to content

Commit 1f3f2bf

Browse files
committed
Try to make Firefox auto-shutdown on Windows more effective
1 parent d5771eb commit 1f3f2bf

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/interceptors/fresh-firefox.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ abstract class Firefox implements Interceptor {
180180
if (process.platform === "win32") {
181181
// Firefox spawns a child process on Windows, and doesn't let us kill it at all.
182182
// To fix this, we kill all firefox instances that were started with this exact same URL.
183-
await windowsKillByCliMatch(`*\\firefox.exe*${initialUrl}`).catch(console.log);
183+
await windowsKillByCliMatch(`*firefox.exe*${initialUrl}`).catch(console.log);
184184
} else {
185185
normalStop();
186186
}
@@ -325,8 +325,10 @@ abstract class Firefox implements Interceptor {
325325
if (this.isActive(proxyPort)) {
326326
const browser = this.activeBrowsers[proxyPort];
327327
const closePromise = new Promise((resolve) => browser.process.once('close', resolve));
328-
browser.stop();
329-
await closePromise;
328+
await Promise.all([
329+
browser.stop(), // Await required, as on Windows this is actually async & slow
330+
closePromise
331+
]);
330332
}
331333
}
332334

@@ -335,7 +337,7 @@ abstract class Firefox implements Interceptor {
335337
Object.keys(this.activeBrowsers).map((proxyPort) => this.deactivate(proxyPort))
336338
);
337339
if (profileSetupBrowser) {
338-
profileSetupBrowser.stop();
340+
await profileSetupBrowser.stop(); // As above - on Windows this is async
339341
return new Promise((resolve) => profileSetupBrowser!.process.once('close', resolve));
340342
}
341343
}

src/shutdown.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function shutdown(code: number, cause: string) {
2828

2929
await Promise.race([
3030
shutdownPromises,
31-
delay(2000) // After 2 seconds, we just close anyway, we're done.
31+
delay(3000) // After 3 seconds, we just close anyway, we're done.
3232
]);
3333

3434
process.exit(code);

0 commit comments

Comments
 (0)