{"record":{"id":"afe51ff0c0d33116","repo":"slymnoyann/hey-1","slug":"no-response-from-refresh","errorCode":null,"errorMessage":"No response from refresh","messagePattern":"No response from refresh","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/helpers/tokenManager.ts","lineNumber":21,"sourceCode":"import { RefreshDocument, type RefreshMutation } from \"@/indexer/generated\";\nimport { signIn, signOut } from \"@/store/persisted/useAuthStore\";\nimport type { JwtPayload } from \"@/types/jwt\";\n\nlet refreshPromise: Promise<string> | null = null;\nconst MAX_RETRIES = 5;\n\nconst executeTokenRefresh = async (refreshToken: string): Promise<string> => {\n  try {\n    for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {\n      const { data } = await apolloClient.mutate<RefreshMutation>({\n        mutation: RefreshDocument,\n        variables: { request: { refreshToken } }\n      });\n\n      const refreshResult = data?.refresh;\n\n      if (!refreshResult) {\n        throw new Error(\"No response from refresh\");\n      }\n\n      if (refreshResult.__typename === \"AuthenticationTokens\") {\n        const { accessToken: newAccessToken, refreshToken: newRefreshToken } =\n          refreshResult;\n\n        if (!newAccessToken || !newRefreshToken) {\n          throw new Error(\"Missing tokens in refresh response\");\n        }\n\n        signIn({\n          accessToken: newAccessToken,\n          refreshToken: newRefreshToken\n        });\n\n        return newAccessToken;\n      }\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/slymnoyann/hey-1/blob/88c8f9d55340d57a37846ff72f55c2c604e3a566/src/helpers/tokenManager.ts#L3-L39","documentation":"Thrown by executeTokenRefresh when the GraphQL refresh mutation resolves but data.refresh is null or undefined. In other words, the server responded successfully (no GraphQL error) yet the refresh field is absent from the response payload, so there is nothing to authenticate with.","triggerScenarios":"Calling the refresh mutation when the server returns a 200 response with an errors array consumed silently by the client, a partial response where the refresh field is missing, or a network/transport layer that resolves with undefined data (offline or interrupted request).","commonSituations":"Expired or malformed refresh token that the server rejects softly, Apollo/GraphQL client misconfiguration swallowing errors into a partial data object, API schema changes removing the refresh field, or intermittent network failures where data is undefined.","solutions":["Check whether the refresh token in storage is expired/malformed; clear it and force re-login if so","Log the full GraphQL result (data and errors) to see whether the mutation returned errors that were hidden","Verify the refresh mutation query string still matches the current API schema","Add offline detection before attempting refresh, and treat undefined data as a retryable network condition"],"exampleFix":"// before\nif (!refreshResult) {\n  throw new Error(\"No response from refresh\");\n}\n\n// after\nif (!refreshResult) {\n  if (typeof navigator !== \"undefined\" && !navigator.onLine) {\n    throw new Error(\"Network unavailable during token refresh\");\n  }\n  throw new Error(\"No response from refresh\");\n}","handlingStrategy":"retry","validationCode":"if (!refreshToken || typeof refreshToken !== \"string\") {\n  signOut();\n  throw new Error(\"No refresh token available\");\n}\nif (typeof navigator !== \"undefined\" && !navigator.onLine) {\n  throw new Error(\"Offline; cannot refresh tokens\");\n}","typeGuard":"const hasRefreshPayload = (d: unknown): d is { refresh: unknown } =>\n  typeof d === \"object\" && d !== null && \"refresh\" in d && (d as { refresh: unknown }).refresh != null;","tryCatchPattern":"try {\n  const token = await refreshTokens(refreshToken);\n} catch (e) {\n  if (e instanceof Error && e.message === \"No response from refresh\") {\n    await new Promise((r) => setTimeout(r, 2000));\n    return refreshTokens(refreshToken); // one manual retry\n  }\n  throw e;\n}","preventionTips":["Clear corrupted tokens from storage on startup","Use an Apollo error-link so GraphQL errors surface instead of yielding empty data","Run silent refresh proactively before the access token expires"],"tags":["authentication","graphql","token-refresh","session"],"backgroundTag":"refresh-token-failure","analyzedSha":"88c8f9d55340d57a37846ff72f55c2c604e3a566","analyzedAt":"2026-08-28T16:20:43.640Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}