can1357/oh-my-pi · error · Error
Smithery auth polling failed: ${response.status} ${response.
Error message
Smithery auth polling failed: ${response.status} ${response.statusText} What it means
Generic failure thrown by pollSmitheryCliAuthSession when the poll endpoint returns a non-OK status other than 404/410 (those are reported as session-expired instead). Includes status code and statusText, e.g. 500 on a Smithery server error or 429 when rate limited.
Source
Thrown at packages/coding-agent/src/mcp/smithery-auth.ts:63
});
if (!response.ok) {
throw new Error(`Failed to create Smithery auth session: ${response.status} ${response.statusText}`);
}
return (await response.json()) as SmitheryCliAuthSession;
}
export async function pollSmitheryCliAuthSession(
sessionId: string,
signal?: AbortSignal,
): Promise<SmitheryCliPollResponse> {
const response = await fetch(`${SMITHERY_URL}/api/auth/cli/poll/${sessionId}`, {
signal: withTimeoutSignal(SMITHERY_POLL_TIMEOUT_MS, signal),
});
if (!response.ok) {
if (response.status === 404 || response.status === 410) {
throw new Error("Smithery login session expired. Please try again.");
}
throw new Error(`Smithery auth polling failed: ${response.status} ${response.statusText}`);
}
return (await response.json()) as SmitheryCliPollResponse;
}
export async function getSmitheryApiKey(): Promise<string | undefined> {
const envKey = normalizeApiKey(process.env.SMITHERY_API_KEY);
if (envKey) return envKey;
const authPath = getSmitheryAuthPath();
try {
const payload = (await Bun.file(authPath).json()) as SmitheryAuthPayload;
return normalizeApiKey(payload.apiKey);
} catch (error) {
if (isEnoent(error)) return undefined;
logger.warn("Failed to read Smithery auth file, treating as missing", { path: authPath, error });
return undefined;
}
}View on GitHub (pinned to 9690622007)
Solutions
- Check the status in the message: 5xx means wait and retry; 429 means slow down polling
- Retry the login flow after a short backoff
- Check Smithery status page / network connectivity if errors persist
- Fall back to manual API key entry from the Smithery dashboard
Example fix
// before: tight polling loop without backoff
while (!done) await pollSmitheryCliAuthSession(id);
// after: backoff between polls
while (!done) {
await pollSmitheryCliAuthSession(id);
await Bun.sleep(pollIntervalMs);
pollIntervalMs = Math.min(pollIntervalMs * 2, 10000);
} Defensive patterns
Strategy: retry
Validate before calling
// check reachability before starting the poll loop
const ok = await fetch(`${smitheryUrl}/api/health`, { signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);
if (!ok) throw new Error("Smithery API unreachable"); Type guard
function isPollFailure(err: unknown): err is Error {
return err instanceof Error && err.message.startsWith("Smithery auth polling failed:");
} Try / catch
try {
const res = await pollSmitheryCliAuthSession(sessionId, signal);
} catch (err) {
if (isPollFailure(err) && /5\d\d/.test(err.message)) {
await Bun.sleep(backoffMs);
return pollWithBackoff(); // retry on server errors only
}
throw err;
} Prevention
- Poll with exponential backoff, not a tight loop, to avoid 429s
- Only retry on 5xx/429; 4xx statuses other than expiry should surface to the user
- Respect the poll interval returned by the session creation response if provided
- Monitor Smithery status before automating logins in CI
When it happens
Trigger: Calling pollSmitheryCliAuthSession and receiving 429 (polling too aggressively), 5xx (Smithery server error), 401/403, or any other unexpected non-OK status.
Common situations: Smithery service outage or degradation, tight polling loops triggering rate limits, intermediary proxies returning error pages.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to create Smithery auth session: ${response.status} $
- Perplexity ask API error (${response.status}): ${errorText}
- V2 remote compaction failed (${response.status} ${response.s
- Bedrock HTTP ${response.status}: ${errBody.slice(0, 1000)}
- sso-role
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/5b2674dc7f7375f2.
Report an issue: GitHub.