diegosouzapw/OmniRoute · error · Error
Clerk token refresh returned HTTP
Error message
Clerk token refresh returned HTTP ${resp.status} What it means
Step 2 of the Clerk flow: POST /v1/client/sessions/{id}/tokens (session JWT refresh) returned non-2xx. Clerk accepted the session id but refused to mint a new JWT — typically an expired __client cookie, a revoked session, or a transient Clerk outage; the embedded status distinguishes auth rejection (401/403) from server errors (5xx).
Solutions
- On 401/403, refresh the __client cookie by re-authenticating with Adapta
- On 5xx/429, retry after a short backoff — the token endpoint is transiently unavailable
- Confirm the connection is not using a session that was revoked in the Adapta account settings
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at open-sse/executors/adapta-web.ts:140 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/3446720940f98783.
Report an issue: GitHub.
Appendix: source
Thrown at open-sse/executors/adapta-web.ts:140
async function refreshSessionJwt(
clientJwt: string,
sessionId: string,
signal?: AbortSignal | null,
log?: ExecuteInput["log"]
): Promise<string> {
const resp = await fetch(`${ADAPTA_CLERK_URL}/v1/client/sessions/${sessionId}/tokens`, {
method: "POST",
headers: {
Cookie: `__client=${clientJwt}`,
"Content-Type": "application/json",
"User-Agent": USER_AGENT,
Origin: ADAPTA_APP_URL,
},
signal: signal ?? undefined,
});
if (!resp.ok) {
throw new Error(`Clerk token refresh returned HTTP ${resp.status}`);
}
const body = await resp.json();
const jwt = body?.jwt;
if (typeof jwt !== "string" || !jwt.startsWith("eyJ")) {
throw new Error("Clerk token refresh did not return a valid JWT");
}
log?.info?.("ADAPTA-WEB", `Got fresh session JWT (${jwt.length} chars)`);
return jwt;
}
/** Returns a valid (non-expired) session JWT, refreshing if necessary. */
async function getSessionJwt(
clientJwt: string,
signal?: AbortSignal | null,
log?: ExecuteInput["log"]
): Promise<string> {View on GitHub (pinned to a179ffed5b)