From 0a3d2a91a616f9d5b9b094572c2885a3a5903505 Mon Sep 17 00:00:00 2001 From: leeguooooo Date: Thu, 11 Jun 2026 21:30:37 +0900 Subject: [PATCH] =?UTF-8?q?fix(connect):=20self-heal=20the=20relay=20silen?= =?UTF-8?q?tly=20=E2=80=94=20~15s=20retry,=20no=20user=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fork.40 errored after 5s ("reload the extension"), which still pushed the problem onto the user. Extend the relay-reconnect wait to ~15s when the extension is installed: enough for the MV3 service worker to wake and reconnect on its own (onStartup after a Chrome restart, or the keepalive alarm). The loop re-checks the relay file each iteration, so a mid-wait recovery is picked up instantly and the full window is only spent when the extension is genuinely down. End users no longer have to do anything when the relay blips. --- cli/src/native/cdp/chrome.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/src/native/cdp/chrome.rs b/cli/src/native/cdp/chrome.rs index 936e227..f9f0482 100644 --- a/cli/src/native/cdp/chrome.rs +++ b/cli/src/native/cdp/chrome.rs @@ -790,8 +790,14 @@ pub async fn auto_connect_cdp() -> Result { // the extension is set up we must NEVER fall through to the raw :9222 path // below: that pops Chrome 136+'s "Allow remote debugging?" dialog, the exact // thing the extension exists to avoid. + // ~15s of retries (500ms apart) when the extension is installed: long enough + // for the MV3 service worker to wake and reconnect on its own (onStartup + // after a Chrome restart, or the keepalive alarm) so the relay self-heals + // with NO user action. The loop re-checks the relay file every iteration, so + // a recovery mid-wait is picked up immediately — the full window is only ever + // spent when the extension is genuinely down. let host_installed = crate::connect::host_installed(); - let relay_attempts = if host_installed { 10 } else { 1 }; + let relay_attempts = if host_installed { 30 } else { 1 }; for attempt in 0..relay_attempts { if let Some(relay) = crate::connect::relay_url() { // The relay is a local CDP-over-WS endpoint we connect to like Chrome.