can1357/oh-my-pi · error
OAuth flow timed out. Please try again.
Error message
OAuth flow timed out. Please try again.
What it means
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.
Source
Thrown at packages/coding-agent/src/modes/controllers/mcp-command-controller.ts:1032
return {
credentialId,
clientId: flow.resolvedClientId,
resource: flow.resource,
};
} catch (error) {
// Esc, an external abort, or a newer MCP flow are neutral
// cancellations. The timeout path also aborts the controller but does
// not set this flag, so it remains a surfaced error.
if (cancellationRequested) {
throw new MCPOAuthCancelledError();
}
const errorMsg = error instanceof Error ? error.message : String(error);
// Provide helpful error messages based on failure type
if (errorMsg.includes("timeout") || errorMsg.includes("timed out")) {
throw new Error("OAuth flow timed out. Please try again.");
} else if (errorMsg.includes("403") || errorMsg.includes("unauthorized")) {
throw new Error("OAuth authorization failed. Please check your client credentials.");
} else if (errorMsg.includes("invalid_grant")) {
throw new Error("OAuth authorization code is invalid or expired. Please try again.");
} else if (errorMsg.includes("ECONNREFUSED") || errorMsg.includes("fetch failed")) {
throw new Error("Could not connect to OAuth server. Please check the URLs and your network connection.");
} else {
throw new Error(`OAuth authentication failed: ${errorMsg}`);
}
} finally {
this.ctx.editor.onEscape = originalOnEscape;
externalSignal?.removeEventListener("abort", onExternalAbort);
manualInputClaim?.clear("Manual MCP OAuth input cleared");
flowClaim.release();
}
}
/**View on GitHub (pinned to 9690622007)
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
Defensive patterns
Strategy: retry
Validate before calling
// Pre-check endpoint responsiveness before starting the flow
const ok = await fetch(tokenUrl, { method: 'HEAD', signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);
if (!ok) console.warn('OAuth server slow or unreachable — expect possible timeout'); Try / catch
try {
await runMcpOAuthFlow();
} catch (err) {
if (err instanceof Error && err.message === 'OAuth flow timed out. Please try again.') {
await runMcpOAuthFlow(); // one bounded retry
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- xAI device-code request failed: ${error instanceof Error ? e
- xAI device-code token polling failed: ${error instanceof Err
- Could not connect to OAuth server. Please check the URLs and
- timed out: {command}
- AnthropicConnectionTimeoutError
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/c90b81ccfe9018d7.
Report an issue: GitHub.