From 8fbc003a30bcabc6ce5d9f04e296d8a933ab5569 Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Fri, 27 Feb 2026 14:02:50 +0000 Subject: [PATCH] feat: Enhance runExecution function with proactive browser health checks to prevent zombie instances --- .../MonitorTypes/SyntheticMonitorWorker.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Probe/Utils/Monitors/MonitorTypes/SyntheticMonitorWorker.ts b/Probe/Utils/Monitors/MonitorTypes/SyntheticMonitorWorker.ts index fa0853af0d..5892c350ff 100644 --- a/Probe/Utils/Monitors/MonitorTypes/SyntheticMonitorWorker.ts +++ b/Probe/Utils/Monitors/MonitorTypes/SyntheticMonitorWorker.ts @@ -452,6 +452,14 @@ async function runExecution(config: WorkerConfig): Promise { context = null; } + // In --single-process mode, closing a context can destabilize the browser. + // Proactively check health so the next execution doesn't waste time on a zombie. + if (currentBrowser && !currentBrowser.isConnected()) { + currentBrowser = null; + currentBrowserType = null; + currentProxyServer = null; + } + // Convert screenshots from Buffer to base64 if (returnObj["screenshots"]) { const screenshots: Record = returnObj[ @@ -485,6 +493,13 @@ async function runExecution(config: WorkerConfig): Promise { // ignore cleanup errors } } + + // Proactively detect zombie browser after context cleanup + if (currentBrowser && !currentBrowser.isConnected()) { + currentBrowser = null; + currentBrowserType = null; + currentProxyServer = null; + } } return workerResult;