diff --git a/extensions/ab-connect/background.js b/extensions/ab-connect/background.js index 1c5dbfd..0f5dd07 100644 --- a/extensions/ab-connect/background.js +++ b/extensions/ab-connect/background.js @@ -355,9 +355,33 @@ chrome.debugger.onEvent.addListener((source, method, params) => }), ) -chrome.debugger.onDetach.addListener((source) => - void whenReady(() => { - if (source.tabId) detachTab(source.tabId, true) +chrome.debugger.onDetach.addListener((source, reason) => + void whenReady(async () => { + const tabId = source.tabId + if (!tabId) return + detachTab(tabId, true) + // A cross-process navigation (e.g. an SSO redirect like + // login.account.rakuten.com that swaps the render process / spawns OOPIFs) + // detaches the debugger, but the TAB survives. Without re-attaching, the + // session goes permanently stale and even open/navigate fails — exactly the + // #19 follow-up. So proactively re-attach (the stable `cb-tab-` + // session id then restores the daemon's binding). Don't fight a detach the + // user or DevTools initiated. + if (reason === 'canceled_by_user' || reason === 'replaced_with_devtools') return + if (!port) return + // The swapped-in process needs a moment to settle; retry with backoff. + for (let i = 0; i < 6; i++) { + await new Promise((r) => setTimeout(r, 250 + i * 200)) + if (tabs.has(tabId)) return // already re-attached (e.g. via onUpdated) + const tab = await chrome.tabs.get(tabId).catch(() => null) + if (!tab || !eligible(tab)) return // tab gone or now a restricted page + try { + await attachTab(tabId) + return + } catch (e) { + console.warn(`ab-connect: reattach attempt ${i + 1} for tab ${tabId} failed:`, e) + } + } }), ) diff --git a/extensions/ab-connect/manifest.json b/extensions/ab-connect/manifest.json index 9f97558..a1edb1b 100644 --- a/extensions/ab-connect/manifest.json +++ b/extensions/ab-connect/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "chrome-use", - "version": "0.4.4", + "version": "0.4.5", "description": "Let chrome-use drive your logged-in Chrome \u2014 install once, no token, no per-use confirmation.", "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6vQIyscGIPYPZdSpPwPL0+0gxUROyRgCpmvCSDoc8XUm4qm97VbKnD9Ijc1lV22lNWZtE78gaRjt6BeSfuMgnBymnhLKjN1gU6AI5QUU0mrJyeHdWKvrKQR5FmsM2A7Xr1ykE2SiiS8zNUS3Y/6O5l+Nva7wrVy6E4a2dkBVQkOsu+DV+nEZvhIyuDY5D5SPXqNwUTWTaglwj5mjvHz36xSwCWlPmrtJ+ED0AUyrb2z4GIOmvk4kqtBVrh/UD058klLo4CkYOnIybB5aV6WYuwarfPY4bF/dLggPem+ewLNTUNBuwrxj/A4nUv0LJTuRO8rR7f8WR9qnRCY0Ic5saQIDAQAB", "icons": {