{"record":{"id":"c4f9c274bbaaa8eb","repo":"jackwener/OpenCLI","slug":"midjourney-login","errorCode":null,"errorMessage":"Midjourney login","messagePattern":"Midjourney login","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/login.js","lineNumber":37,"sourceCode":"  columns: ['status', 'logged_in', 'site', 'plan', 'subscription_status'],\n  func: async (page, kwargs) => {\n    const timeout = normalizePositiveInt(kwargs.timeout, 300, 900, '--timeout');\n    await page.goto(MIDJOURNEY_IMAGINE_URL);\n    try {\n      return { status: 'already_logged_in', ...await midjourneyIdentity(page) };\n    } catch (error) {\n      if (!(error instanceof AuthRequiredError)) throw error;\n    }\n    const deadline = Date.now() + timeout * 1000;\n    while (Date.now() < deadline) {\n      await page.wait(2);\n      try {\n        return { status: 'login_complete', ...await midjourneyIdentity(page) };\n      } catch (error) {\n        if (!(error instanceof AuthRequiredError)) throw error;\n      }\n    }\n    throw new TimeoutError(\n      'Midjourney login', timeout,\n      'Finish signing in in the foreground Chrome window, then retry `opencli midjourney whoami`.',\n    );\n  },\n});\n","sourceCodeStart":19,"sourceCodeEnd":43,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/login.js#L19-L43","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Finish signing in in the foreground Chrome window, then run `opencli midjourney whoami` to confirm the session is established (as the error message advises).","Re-run `opencli midjourney login --timeout 900` to allow up to 15 minutes for sign-in including 2FA.","Complete login manually in Chrome first, then retry the command (it returns 'already_logged_in' immediately).","Don't run this command in headless/CI environments — interactive login requires a human at the browser."],"exampleFix":"// before\nopencli midjourney login --timeout 60   # too short with 2FA\n// after\nopencli midjourney login --timeout 900","handlingStrategy":"validation","validationCode":"// Only run interactive login where a human can complete it, and allow enough time\nif (!process.stdout.isTTY && !forceInteractive) {\n  throw new Error('midjourney login requires an interactive session; log in via Chrome first.');\n}\nconst timeout = Math.min(Math.max(1, Number(rawTimeout ?? 300)), 900);\nif (timeout < 120) console.warn('timeout under 120s may expire before 2FA completes');","typeGuard":"function isLoginTimeoutError(e) { return e instanceof TimeoutError || (e && e.name === 'TimeoutError' && /Midjourney login/.test(e.message ?? '')); }","tryCatchPattern":"try {\n  await opencli.midjourney.login({ timeout: 900 });\n} catch (e) {\n  if (isLoginTimeoutError(e)) {\n    // user didn't finish sign-in; check whether they completed it afterwards\n    return opencli.midjourney.whoami();\n  }\n  throw e;\n}","preventionTips":["Log in manually in Chrome once; subsequent commands reuse the persistent session and login returns 'already_logged_in'.","Use --timeout 900 for accounts with 2FA or slow verification flows.","Never invoke this command in headless/CI environments — it requires a foreground browser and human action.","After a timeout, run `opencli midjourney whoami` before retrying login; the sign-in may have completed just after the deadline."],"tags":["timeout","authentication","interactive-login","midjourney"],"backgroundTag":"login-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}