Skip to content

Commit

Permalink
Allow re-activating fresh Chromium browsers
Browse files Browse the repository at this point in the history
This is useful because if you have an old process running, it's easy to
lose it (especially on Mac, where it may be invisible) and this provides
an easy way to ping it back into the foreground.
  • Loading branch information
pimterry committed Sep 26, 2022
1 parent b79064c commit 5438b06
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/interceptors/chromium-based-interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ abstract class FreshChromiumBasedInterceptor implements Interceptor {
}

async activate(proxyPort: number, options: { webExtensionEnabled?: boolean } = {}) {
if (this.isActive(proxyPort)) return;
const alreadyActive = this.isActive(proxyPort);

const hideWarningServer = new HideWarningServer(this.config);
await hideWarningServer.start('https://amiusing.httptoolkit.tech');
Expand All @@ -119,6 +119,8 @@ abstract class FreshChromiumBasedInterceptor implements Interceptor {
await hideWarningServer.completedPromise;
await hideWarningServer.stop();

if (alreadyActive) return; // If we're just opening a new tab, we're done, don't track the process.

this.activeBrowsers[proxyPort] = browser;
browser.process.once('close', async () => {
delete this.activeBrowsers[proxyPort];
Expand Down

0 comments on commit 5438b06

Please sign in to comment.