jackwener/OpenCLI · error · TimeoutError

Midjourney login

Error message

Midjourney login

What it means

TimeoutError('Midjourney login') is thrown by `opencli midjourney login` when interactive login did not complete within the --timeout budget (default 300s, max 900s). The command opens Midjourney in a foreground Chrome window and polls `midjourneyIdentity` every 2 seconds, swallowing AuthRequiredError until the deadline; if the user never finishes signing in, the timeout fires with instructions to retry `opencli midjourney whoami`.

Source

Thrown at clis/midjourney/login.js:37

  columns: ['status', 'logged_in', 'site', 'plan', 'subscription_status'],
  func: async (page, kwargs) => {
    const timeout = normalizePositiveInt(kwargs.timeout, 300, 900, '--timeout');
    await page.goto(MIDJOURNEY_IMAGINE_URL);
    try {
      return { status: 'already_logged_in', ...await midjourneyIdentity(page) };
    } catch (error) {
      if (!(error instanceof AuthRequiredError)) throw error;
    }
    const deadline = Date.now() + timeout * 1000;
    while (Date.now() < deadline) {
      await page.wait(2);
      try {
        return { status: 'login_complete', ...await midjourneyIdentity(page) };
      } catch (error) {
        if (!(error instanceof AuthRequiredError)) throw error;
      }
    }
    throw new TimeoutError(
      'Midjourney login', timeout,
      'Finish signing in in the foreground Chrome window, then retry `opencli midjourney whoami`.',
    );
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Finish signing in in the foreground Chrome window, then run `opencli midjourney whoami` to confirm the session is established (as the error message advises).
  2. Re-run `opencli midjourney login --timeout 900` to allow up to 15 minutes for sign-in including 2FA.
  3. Complete login manually in Chrome first, then retry the command (it returns 'already_logged_in' immediately).
  4. Don't run this command in headless/CI environments — interactive login requires a human at the browser.

Example fix

// before
opencli midjourney login --timeout 60   # too short with 2FA
// after
opencli midjourney login --timeout 900
Defensive patterns

Strategy: validation

Validate before calling

// Only run interactive login where a human can complete it, and allow enough time
if (!process.stdout.isTTY && !forceInteractive) {
  throw new Error('midjourney login requires an interactive session; log in via Chrome first.');
}
const timeout = Math.min(Math.max(1, Number(rawTimeout ?? 300)), 900);
if (timeout < 120) console.warn('timeout under 120s may expire before 2FA completes');

Type guard

function isLoginTimeoutError(e) { return e instanceof TimeoutError || (e && e.name === 'TimeoutError' && /Midjourney login/.test(e.message ?? '')); }

Try / catch

try {
  await opencli.midjourney.login({ timeout: 900 });
} catch (e) {
  if (isLoginTimeoutError(e)) {
    // user didn't finish sign-in; check whether they completed it afterwards
    return opencli.midjourney.whoami();
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `opencli midjourney login` and not completing the sign-in in the foreground Chrome window before --timeout seconds elapse; abandoning the browser window; repeated midjourneyIdentity calls that keep raising AuthRequiredError (not logged in) until Date.now() exceeds deadline; also entering credentials slowly with a small --timeout like 60.

Common situations: User walks away and misses the 5-minute default window; two-factor authentication or email verification delays login past the timeout; running the command headless/in CI where no human can complete the interactive login; Midjourney login flow changed (CAPTCHA) blocking completion; expired session requiring re-login but nobody at the keyboard.

Related errors


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