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;