{"record":{"id":"c90b81ccfe9018d7","repo":"can1357/oh-my-pi","slug":"oauth-flow-timed-out-please-try-again","errorCode":null,"errorMessage":"OAuth flow timed out. Please try again.","messagePattern":"OAuth flow timed out\\. Please try again\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/controllers/mcp-command-controller.ts","lineNumber":1032,"sourceCode":"\n\t\t\treturn {\n\t\t\t\tcredentialId,\n\t\t\t\tclientId: flow.resolvedClientId,\n\t\t\t\tresource: flow.resource,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\t// Esc, an external abort, or a newer MCP flow are neutral\n\t\t\t// cancellations. The timeout path also aborts the controller but does\n\t\t\t// not set this flag, so it remains a surfaced error.\n\t\t\tif (cancellationRequested) {\n\t\t\t\tthrow new MCPOAuthCancelledError();\n\t\t\t}\n\n\t\t\tconst errorMsg = error instanceof Error ? error.message : String(error);\n\n\t\t\t// Provide helpful error messages based on failure type\n\t\t\tif (errorMsg.includes(\"timeout\") || errorMsg.includes(\"timed out\")) {\n\t\t\t\tthrow new Error(\"OAuth flow timed out. Please try again.\");\n\t\t\t} else if (errorMsg.includes(\"403\") || errorMsg.includes(\"unauthorized\")) {\n\t\t\t\tthrow new Error(\"OAuth authorization failed. Please check your client credentials.\");\n\t\t\t} else if (errorMsg.includes(\"invalid_grant\")) {\n\t\t\t\tthrow new Error(\"OAuth authorization code is invalid or expired. Please try again.\");\n\t\t\t} else if (errorMsg.includes(\"ECONNREFUSED\") || errorMsg.includes(\"fetch failed\")) {\n\t\t\t\tthrow new Error(\"Could not connect to OAuth server. Please check the URLs and your network connection.\");\n\t\t\t} else {\n\t\t\t\tthrow new Error(`OAuth authentication failed: ${errorMsg}`);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.ctx.editor.onEscape = originalOnEscape;\n\t\t\texternalSignal?.removeEventListener(\"abort\", onExternalAbort);\n\t\t\tmanualInputClaim?.clear(\"Manual MCP OAuth input cleared\");\n\t\t\tflowClaim.release();\n\t\t}\n\t}\n\n\t/**","sourceCodeStart":1014,"sourceCodeEnd":1050,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts#L1014-L1050","documentation":"The MCP OAuth flow failed and the underlying error message contained 'timeout' or 'timed out'. The controller maps that to this user-facing error, meaning the OAuth round-trip (browser auth, callback, or token exchange) did not complete within the allotted time.","triggerScenarios":"User takes too long to complete browser authorization; the OAuth callback server never receives the redirect; the token endpoint is slow and exceeds the flow's timeout window.","commonSituations":"Slow network or VPN delaying the provider's authorize page; leaving the browser tab open too long before approving; an OAuth server that is down or unresponsive.","solutions":["Retry the OAuth flow and complete the browser authorization promptly","Verify the OAuth server URLs are reachable (curl the token/auth endpoints)","Check network/VPN/proxy connectivity to the provider","Increase the flow timeout if the provider is known to be slow"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-check endpoint responsiveness before starting the flow\nconst ok = await fetch(tokenUrl, { method: 'HEAD', signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);\nif (!ok) console.warn('OAuth server slow or unreachable — expect possible timeout');","typeGuard":null,"tryCatchPattern":"try {\n  await runMcpOAuthFlow();\n} catch (err) {\n  if (err instanceof Error && err.message === 'OAuth flow timed out. Please try again.') {\n    await runMcpOAuthFlow(); // one bounded retry\n  }\n}","preventionTips":["Complete browser authorization promptly once the flow starts","Check endpoint latency before initiating OAuth","Warn users on slow networks that the flow has a time limit"],"tags":["oauth","timeout","mcp","network"],"backgroundTag":"oauth-flow-timeout","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}