Skip to content

Commit e729481

Browse files
committed
Improve handling of firefox immediate restart edge cases
1 parent f7ab587 commit e729481

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/interceptors/fresh-firefox.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ export class FreshFirefox implements Interceptor {
180180
return browser;
181181
}
182182

183+
// Create the profile. We need to run FF to do its setup, then close it & edit more ourselves.
183184
async setupFirefoxProfile() {
184185
const messageServer = new MessageServer(
185186
this.config,
@@ -279,11 +280,17 @@ export class FreshFirefox implements Interceptor {
279280
});
280281

281282
browsers[proxyPort] = browser;
282-
browser.process.once('close', (exitCode) => {
283+
browser.process.once('close', async (exitCode) => {
283284
console.log('Firefox closed');
285+
delete browsers[proxyPort];
284286

287+
// It seems maybe this can happen when firefox is just updated - it starts and
288+
// closes immediately, but loses some settings along the way. In that case, the 2nd
289+
// run will still try to load the cert check server. Keep it up for a sec so
290+
// that users get a clean error in this case.
291+
await delay(2000);
285292
certCheckServer.stop();
286-
delete browsers[proxyPort];
293+
287294
if (!certCheckSuccessful) {
288295
reportError(`Firefox certificate check ${
289296
certCheckSuccessful === false

0 commit comments

Comments
 (0)