jackwener/OpenCLI · error · CommandExecutionError

Discord did not finish navigating to the requested channel.

Error message

Discord did not finish navigating to the requested channel. Last observed URL: ${lastState?.url || 'unknown'}

What it means

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.

Source

Thrown at clis/discord-app/utils.js:539

export async function waitForDiscordRoute(page, target, options = {}) {
    const timeoutMs = options.timeoutMs ?? 8000;
    const intervalSeconds = options.intervalSeconds ?? 0.5;
    const started = Date.now();
    let lastState = null;

    while (Date.now() - started <= timeoutMs) {
        lastState = requireObjectEvaluateResult(await page.evaluate(buildRouteStateScript()), 'Discord route state');
        const route = lastState?.route;
        if (route && String(route.guild_id) === String(target.guild_id) && String(route.channel_id) === String(target.channel_id)) {
            if (!target.thread_id || String(route.thread_id || '') === String(target.thread_id)) {
                return lastState;
            }
        }
        await page.wait(intervalSeconds);
    }

    throw new CommandExecutionError(
        'Discord did not finish navigating to the requested channel.',
        `Last observed URL: ${lastState?.url || 'unknown'}`,
    );
}

export async function waitForDiscordContent(page, kind = 'messages', options = {}) {
    const timeoutMs = options.timeoutMs ?? 5000;
    const intervalSeconds = options.intervalSeconds ?? 0.5;
    const started = Date.now();
    let lastState = null;

    while (Date.now() - started <= timeoutMs) {
        lastState = requireObjectEvaluateResult(await page.evaluate(buildRouteStateScript()), 'Discord route state');
        if (kind === 'messages' && lastState?.has_messages) return lastState;
        if (kind === 'threads' && lastState?.has_threads) return lastState;
        await page.wait(intervalSeconds);
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the Last observed URL in the message to see where navigation stalled (login page, wrong channel, index route).
  2. Increase the wait deadline/interval options if the app is just slow to load.
  3. Re-authenticate the Discord session (log in via the app profile) and retry.
  4. Retry the command; verify the channel is accessible to the logged-in account.

Example fix

// before
await waitForDiscordRoute(page, target); // default deadline, cold app
// after
await waitForDiscordRoute(page, target, { timeoutSeconds: 60, intervalSeconds: 2 }); // more time on slow loads
Defensive patterns

Strategy: retry

Validate before calling

// pre-check the session/routes are alive before waiting
await page.goto('https://discord.com/channels/@me');
if ((await page.url()).includes('login')) throw new Error('Discord session expired; re-login first');

Type guard

null

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/20be1f798ec9ee80. Report an issue: GitHub.