{"record":{"id":"c143cea1a516b161","repo":"tinyhumansai/openhuman","slug":"request-timed-out-please-try-again","errorCode":null,"errorMessage":"Request timed out. Please try again.","messagePattern":"Request timed out\\. Please try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"app/src/services/api/authApi.ts","lineNumber":40,"sourceCode":"\n  try {\n    const versionHeaders = await getClientVersionHeaders();\n    const response = await fetch(`${backendUrl}/auth/email/send-link`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json', ...versionHeaders },\n      body: JSON.stringify({ email, frontendRedirectUri }),\n      signal: controller.signal,\n    });\n    if (!response.ok) {\n      const body = (await response.json().catch(() => ({}))) as { error?: string };\n      throw new Error(body.error ?? `Failed to send magic link (${response.status})`);\n    }\n  } catch (error) {\n    if (\n      (error instanceof DOMException && error.name === 'AbortError') ||\n      (error instanceof Error && error.name === 'AbortError')\n    ) {\n      throw new Error('Request timed out. Please try again.');\n    }\n    throw error;\n  } finally {\n    window.clearTimeout(timeoutId);\n  }\n}\n\n/**\n * Consume a verified login token and return the JWT.\n * Works for both Telegram and OAuth login tokens.\n * POST /telegram/login-tokens/:token/consume (no auth required)\n */\nexport async function consumeLoginToken(loginToken: string): Promise<string> {\n  const response = await callCoreRpc<{ result: { jwtToken: string } }>({\n    method: 'openhuman.auth.consume_login_token',\n    params: { loginToken },\n  });\n  const jwtToken = response.result?.jwtToken;","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/app/src/services/api/authApi.ts#L22-L58","documentation":"Thrown by the magic-link flow when the AbortController wired to window.setTimeout(timeoutMs) fires and aborts the fetch, producing a DOMException/Error with name 'AbortError'. It is a client-side timeout translation: the request took longer than the configured budget and was cancelled locally — the server may never have seen it complete. The catch converts AbortError into a user-friendly retry message.","triggerScenarios":"Backend /auth/email/send-link is slow (cold start, email provider latency) and exceeds timeoutMs; the user is on a slow/high-latency network; backendUrl resolves to an endpoint that hangs (wrong port, firewall drop).","commonSituations":"First request after backend deploy (cold lambda/container); mobile/tethered connections; a mistyped backend URL that black-holes instead of refusing; timeouts set aggressively low in tests.","solutions":["Retry the request — transient latency is the most common cause and the operation (sending an email link) is idempotent from the user's perspective.","Check network/backend health if it reproducibly times out: is the backend up, does /health respond quickly?","Raise timeoutMs if the backend is legitimately slow (e.g. dev environments with cold starts).","Verify backendUrl is correct — a hanging (not refused) endpoint is often a wrong host/port behind a firewall."],"exampleFix":"// before\nwindow.setTimeout(() => controller.abort(), timeoutMs);\n...\nif ((error instanceof DOMException && error.name === 'AbortError') || ...) {\n  throw new Error('Request timed out. Please try again.');\n}\n\n// after — retry once on timeout before giving up\nasync function sendWithRetry(email: string, uri: string, timeoutMs: number) {\n  try {\n    return await sendMagicLinkRequest(email, uri, timeoutMs);\n  } catch (e) {\n    if (e instanceof Error && e.message === 'Request timed out. Please try again.') {\n      return await sendMagicLinkRequest(email, uri, timeoutMs); // one retry\n    }\n    throw e;\n  }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"function isTimeoutError(e: unknown): boolean {\n  return e instanceof Error && e.message === 'Request timed out. Please try again.';\n}\n\ntry {\n  await sendMagicLink(email, uri);\n} catch (e) {\n  if (isTimeoutError(e)) {\n    await sleep(1000);\n    await sendMagicLink(email, uri); // single retry — the operation is idempotent\n  } else throw e;\n}","preventionTips":["Size timeoutMs to real backend latency (cold starts need more).","Show a retry affordance in the UI for timeout-specific errors.","AbortController per request — never share one controller across requests."],"tags":["timeout","abortcontroller","auth","network","retryable"],"backgroundTag":"request-timeout","analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}