{"record":{"id":"20be1f798ec9ee80","repo":"jackwener/OpenCLI","slug":"discord-did-not-finish-navigating-to-the-requested","errorCode":null,"errorMessage":"Discord did not finish navigating to the requested channel. Last observed URL: ${lastState?.url || 'unknown'}","messagePattern":"Discord did not finish navigating to the requested channel\\. Last observed URL: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/discord-app/utils.js","lineNumber":539,"sourceCode":"\nexport async function waitForDiscordRoute(page, target, options = {}) {\n    const timeoutMs = options.timeoutMs ?? 8000;\n    const intervalSeconds = options.intervalSeconds ?? 0.5;\n    const started = Date.now();\n    let lastState = null;\n\n    while (Date.now() - started <= timeoutMs) {\n        lastState = requireObjectEvaluateResult(await page.evaluate(buildRouteStateScript()), 'Discord route state');\n        const route = lastState?.route;\n        if (route && String(route.guild_id) === String(target.guild_id) && String(route.channel_id) === String(target.channel_id)) {\n            if (!target.thread_id || String(route.thread_id || '') === String(target.thread_id)) {\n                return lastState;\n            }\n        }\n        await page.wait(intervalSeconds);\n    }\n\n    throw new CommandExecutionError(\n        'Discord did not finish navigating to the requested channel.',\n        `Last observed URL: ${lastState?.url || 'unknown'}`,\n    );\n}\n\nexport async function waitForDiscordContent(page, kind = 'messages', options = {}) {\n    const timeoutMs = options.timeoutMs ?? 5000;\n    const intervalSeconds = options.intervalSeconds ?? 0.5;\n    const started = Date.now();\n    let lastState = null;\n\n    while (Date.now() - started <= timeoutMs) {\n        lastState = requireObjectEvaluateResult(await page.evaluate(buildRouteStateScript()), 'Discord route state');\n        if (kind === 'messages' && lastState?.has_messages) return lastState;\n        if (kind === 'threads' && lastState?.has_threads) return lastState;\n        await page.wait(intervalSeconds);\n    }\n","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/utils.js#L521-L557","documentation":"waitForDiscordRoute polls the page state until the Discord route matches the requested channel, waiting intervalSeconds between checks. If navigation never settles to the target route before the deadline, it throws CommandExecutionError including the last observed URL for diagnosis.","triggerScenarios":"The Discord web app failed to navigate to the target channel within the polling window: slow load, login/session loss, an interstitial (update/CAPTCHA/2FA), or the route state never matched the requested guild/channel ids.","commonSituations":"Cold-start Discord profile with heavy initial load; expired session showing the login screen; network throttling in CI; Discord deployed a UI change that alters route detection; navigating to a channel the account cannot access.","solutions":["Check the Last observed URL in the message to see where navigation stalled (login page, wrong channel, index route).","Increase the wait deadline/interval options if the app is just slow to load.","Re-authenticate the Discord session (log in via the app profile) and retry.","Retry the command; verify the channel is accessible to the logged-in account."],"exampleFix":"// before\nawait waitForDiscordRoute(page, target); // default deadline, cold app\n// after\nawait waitForDiscordRoute(page, target, { timeoutSeconds: 60, intervalSeconds: 2 }); // more time on slow loads","handlingStrategy":"retry","validationCode":"// pre-check the session/routes are alive before waiting\nawait page.goto('https://discord.com/channels/@me');\nif ((await page.url()).includes('login')) throw new Error('Discord session expired; re-login first');","typeGuard":"null","tryCatchPattern":"try { await waitForDiscordRoute(page, target, { timeoutSeconds: 45 }); } catch (e) { if (String(e.message).includes('did not finish navigating')) { await retry(() => waitForDiscordRoute(page, target), 2); } else throw e; }","preventionTips":["Inspect the 'Last observed URL' in the error to diagnose stalls (login page vs wrong channel).","Raise timeoutSeconds on cold starts/slow networks.","Ensure the Discord profile is logged in and the channel is accessible to the account.","Warm up the app (load Discord once) before batch operations."],"tags":["discord","navigation","timeout","browser-automation"],"backgroundTag":"navigation-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}