earendil-works/pi · error · Error

Kimi Code token refresh aborted

Error message

Kimi Code token refresh aborted

What it means

Error "Kimi Code token refresh aborted" thrown in earendil-works/pi.

Source

Thrown at packages/ai/src/auth/oauth/kimi-coding.ts:221

				status: "failed",
				message: `Kimi Code device token request failed (status ${response.status})${typeof error === "string" ? `: ${error}${description}` : ""}`,
			};
		},
	});
}

function isRetryableRefreshFailure(response: Response): boolean {
	return response.status === 429 || response.status >= 500;
}

async function refreshToken(oauthHost: string, refreshTokenValue: string, signal: AbortSignal): Promise<TokenResponse> {
	let lastError: Error | undefined;
	for (let attempt = 0; attempt <= REFRESH_MAX_RETRIES; attempt++) {
		if (attempt > 0) {
			await sleep(1000 * 2 ** (attempt - 1), signal);
		}
		if (signal.aborted) {
			throw new Error("Kimi Code token refresh aborted");
		}

		let response: Response;
		try {
			response = await fetch(`${oauthHost}/api/oauth/token`, {
				method: "POST",
				headers: {
					"Content-Type": "application/x-www-form-urlencoded",
					Accept: "application/json",
				},
				body: formUrlEncode({
					client_id: CLIENT_ID,
					grant_type: "refresh_token",
					refresh_token: refreshTokenValue,
				}),
				signal: requestSignal(signal),
			});
		} catch (error) {

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Retry the token refresh; the abort interrupted it.

When it happens

Trigger: Thrown at packages/ai/src/auth/oauth/kimi-coding.ts:221 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/9bdf0d27f53c9650. Report an issue: GitHub.