{"record":{"id":"5b3f9fe366c1936e","repo":"jackwener/OpenCLI","slug":"opencli-navigate-to-targeturl-timed-out-after","errorCode":null,"errorMessage":"[opencli] Navigate to ${targetUrl} timed out after 15s","messagePattern":"\\[opencli\\] Navigate to (.+?) timed out after 15s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extension/src/background.ts","lineNumber":1799,"sourceCode":"        finish();\n      }\n    };\n    chrome.tabs.onUpdated.addListener(listener);\n\n    // Also check if the tab already navigated (e.g. instant cache hit)\n    checkTimer = setTimeout(async () => {\n      try {\n        const currentTab = await chrome.tabs.get(tabId);\n        if (currentTab.status === 'complete' && isNavigationDone(currentTab.url)) {\n          finish();\n        }\n      } catch { /* tab gone */ }\n    }, 100);\n\n    // Timeout fallback with warning\n    timeoutTimer = setTimeout(() => {\n      timedOut = true;\n      console.warn(`[opencli] Navigate to ${targetUrl} timed out after 15s`);\n      finish();\n    }, 15000);\n  });\n\n  let tab = await chrome.tabs.get(tabId);\n\n  // Post-navigation drift detection: if the tab moved to another window\n  // during navigation (e.g. a tab-management extension regrouped it),\n  // try to move it back to maintain session isolation.\n  const postNavigationSession = automationSessions.get(leaseKey);\n  if (postNavigationSession && tab.windowId !== postNavigationSession.windowId) {\n    console.warn(`[opencli] Tab ${tabId} drifted to window ${tab.windowId} during navigation, moving back to ${postNavigationSession.windowId}`);\n    try {\n      await chrome.tabs.move(tabId, { windowId: postNavigationSession.windowId, index: -1 });\n      tab = await chrome.tabs.get(tabId);\n    } catch (moveErr) {\n      console.warn(`[opencli] Failed to recover drifted tab: ${moveErr}`);\n    }","sourceCodeStart":1781,"sourceCodeEnd":1817,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/extension/src/background.ts#L1781-L1817","documentation":"A console warning from the navigation wait helper: when a target page's load/complete event does not fire within 15 seconds, the extension logs this, marks the wait as timed out, and proceeds (finish()) rather than hanging forever. The subsequent command may operate on a partially loaded page.","triggerScenarios":"chrome.tabs.update/get navigation to targetUrl where the load event never completes within 15000ms — slow site, hung network request, or a page whose lifecycle events don't map to the awaited condition.","commonSituations":"Slow or unresponsive target websites; captive portals or proxy auth prompts blocking load; SPAs with long-polling connections that keep the page 'loading'; offline/broken network during automation.","solutions":["Retry the command — transient network slowness often resolves","Verify the target URL is reachable in a normal browser tab","Check proxy/VPN/captive-portal state blocking page load","Increase the navigation timeout in background.ts if 15s is too short for the target site"],"exampleFix":"// before\ntimeoutTimer = setTimeout(() => { ... finish(); }, 15000);\n// after\ntimeoutTimer = setTimeout(() => { ... finish(); }, 30000); // tolerate slow sites","handlingStrategy":"try-catch","validationCode":"const reachable = await fetch(targetUrl, { method: 'HEAD', mode: 'no-cors', signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);\nif (!reachable) warnUserBeforeNavigate();","typeGuard":null,"tryCatchPattern":"const ok = await navigateAndWait(tabId, url, 15000).catch(() => false);\nif (!ok) console.warn('page may be partially loaded');","preventionTips":["Pre-check target URL reachability before navigating","Raise the timeout for slow sites","Ensure proxies/VPNs are not blocking the target","Treat timed-out pages as possibly incomplete before asserting on content"],"tags":["navigation","timeout","chrome-extension"],"backgroundTag":"navigation-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}