Skip to content

Commit 607f921

Browse files
committed
Make sure FF profile setup server is cleaned up properly
1 parent 713633f commit 607f921

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/interceptors/fresh-firefox.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export class FreshFirefox implements Interceptor {
192192
profileSetupBrowser = await this.startFirefox(messageServer);
193193
profileSetupBrowser.process.once('close', (exitCode) => {
194194
console.log("Profile setup Firefox closed");
195+
messageServer.stop();
195196
profileSetupBrowser = undefined;
196197

197198
if (messageShown !== true) {
@@ -274,7 +275,7 @@ export class FreshFirefox implements Interceptor {
274275
certCheckSuccessful = true;
275276
}).catch((e) => {
276277
certCheckSuccessful = false;
277-
reportError(e)
278+
reportError(e);
278279
});
279280

280281
browsers[proxyPort] = browser;

test/interceptors/fresh-firefox.spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import * as _ from 'lodash';
2-
import fetch from 'node-fetch';
31
import { CompletedRequest } from 'mockttp';
42
import { setupInterceptor, itIsAvailable } from './interceptor-test-utils';
53
import { expect } from 'chai';
6-
import { delay } from '../../src/util';
74

85
const interceptorSetup = setupInterceptor('fresh-firefox');
96

107
describe('Firefox interceptor', function () {
11-
this.timeout(5000);
8+
this.timeout(10000);
129

1310
beforeEach(async () => {
1411
const { server } = await interceptorSetup;
@@ -25,11 +22,8 @@ describe('Firefox interceptor', function () {
2522
itIsAvailable(interceptorSetup);
2623

2724
it('successfully makes requests', async function () {
28-
this.timeout(10000);
2925
const { server, interceptor: firefoxInterceptor } = await interceptorSetup;
3026

31-
await firefoxInterceptor.activate(server.port);
32-
3327
const exampleRequestReceived = new Promise<CompletedRequest>((resolve) =>
3428
server.on('request', (req) => {
3529
if (req.url.startsWith('https://amiusing.httptoolkit.tech')) {
@@ -55,6 +49,5 @@ describe('Firefox interceptor', function () {
5549

5650
await interceptor.deactivateAll();
5751
expect(interceptor.isActive(server.port)).to.equal(false);
58-
await delay(500); // Wait to ensure the profile is cleaned up
5952
});
6053
});

0 commit comments

Comments
 (0)