{"record":{"id":"4dfbbd50250206e5","repo":"can1357/oh-my-pi","slug":"smithery-authorization-timed-out-after-5-minutes","errorCode":null,"errorMessage":"Smithery authorization timed out after 5 minutes.","messagePattern":"Smithery authorization timed out after 5 minutes\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/controllers/mcp-command-controller.ts","lineNumber":2408,"sourceCode":"\t\t}\n\t}\n\n\tasync #handleSmitheryLoginWithApiKey(): Promise<boolean> {\n\t\tconst apiKey = await this.#promptSmitheryApiKey(\"Smithery API key (Esc to cancel)\");\n\t\tif (!apiKey) return false;\n\t\tawait saveSmitheryApiKey(apiKey);\n\t\tthis.ctx.showStatus(\"Smithery API key saved.\");\n\t\treturn true;\n\t}\n\n\tasync #waitForSmitheryCliApiKey(sessionId: string, signal: AbortSignal): Promise<string> {\n\t\tconst pollIntervalMs = 2_000;\n\t\tconst timeoutMs = 300_000;\n\t\tconst startedAt = Date.now();\n\n\t\twhile (!signal.aborted) {\n\t\t\tif (Date.now() - startedAt >= timeoutMs) {\n\t\t\t\tthrow new Error(\"Smithery authorization timed out after 5 minutes.\");\n\t\t\t}\n\t\t\tlet response: SmitheryCliPollResponse;\n\t\t\ttry {\n\t\t\t\tresponse = await pollSmitheryCliAuthSession(sessionId, signal);\n\t\t\t} catch (error) {\n\t\t\t\t// A single hung/slow poll aborts with TimeoutError; retry until the deadline.\n\t\t\t\tif (isTimeoutError(error)) continue;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (response.status === \"success\" && response.apiKey) {\n\t\t\t\treturn response.apiKey;\n\t\t\t}\n\t\t\tif (response.status === \"error\") {\n\t\t\t\tthrow new Error(response.message ?? \"Smithery authorization failed.\");\n\t\t\t}\n\t\t\tawait Bun.sleep(pollIntervalMs);\n\t\t}\n","sourceCodeStart":2390,"sourceCodeEnd":2426,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts#L2390-L2426","documentation":"Thrown by #waitForSmitheryCliApiKey when the browser-based Smithery CLI authorization polling loop exceeds its 5-minute deadline (300s timeout, 2s poll interval) without the session reaching a success or error status. The user was asked to authorize OMP in the browser, but approval never arrived in time, so the controller gives up with a timeout.","triggerScenarios":"Running /mcp smithery-login (browser flow) and not completing the browser authorization within 5 minutes — or the poll loop running while the signal never aborts but the session stays 'pending' past the deadline.","commonSituations":"The browser tab was never opened (popup blocked, no browser on a headless box); the user missed the notification; Smithery's login page hung or the session never advanced server-side; the user walked away and came back after the deadline.","solutions":["Re-run /mcp smithery-login and complete the browser authorization promptly (within 5 minutes).","If the browser does not open, copy the 'Authorize URL' shown in the message panel and open it manually.","Skip the browser flow entirely: run /mcp smithery-login and paste your Smithery API key instead (the controller falls back to key input when browser auth fails).","Check Smithery's status — if their auth service is degraded, sessions may never transition to success; retry later."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm the authorize URL is reachable before starting the browser flow\nconst r = await fetch(session.authUrl, { redirect: \"manual\" });\nif (r.type === \"error\" && !(r.status || r.status === 0)) throw new Error(\"Authorize URL unreachable — fix browser/network before login\");","typeGuard":"function isSmitheryAuthTimeout(err: unknown): err is Error {\n  return err instanceof Error && err.message.startsWith(\"Smithery authorization timed out\");\n}","tryCatchPattern":"try {\n  await smitheryLogin();\n} catch (err) {\n  if (isSmitheryAuthTimeout(err)) {\n    // retry once; if it times out again, fall back to pasting an API key\n    return await smitheryApiKeyFallback();\n  }\n  throw err;\n}","preventionTips":["Complete the browser approval promptly — the poll window is 5 minutes.","On headless machines, use the API-key input path instead of waiting for a browser that cannot open.","Allow popups for the authorization domain, or copy the printed Authorize URL manually.","Check Smithery service status if sessions repeatedly never reach success."],"tags":["smithery","oauth","timeout","browser-auth"],"backgroundTag":"authorization-poll-timeout","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}