{"record":{"id":"1ba74636bdb7bdef","repo":"chatboxai/chatbox","slug":"minimax-oauth-timed-out-waiting-for-authorization","errorCode":null,"errorMessage":"MiniMax OAuth timed out waiting for authorization.","messagePattern":"MiniMax OAuth timed out waiting for authorization\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/oauth/providers/minimax.ts","lineNumber":188,"sourceCode":"          }\n\n          if (response.ok && payload.access_token) {\n            return {\n              accessToken: payload.access_token,\n              refreshToken: payload.refresh_token,\n              expiresAt: toExpiresAt(payload.expired_in),\n            }\n          }\n\n          const errorMessage = getMiniMaxErrorMessage(payload, text)\n          if (!response.ok || errorMessage) {\n            throw new Error(`MiniMax OAuth failed: ${errorMessage || text}`)\n          }\n\n          intervalMs = Math.min(Math.round(intervalMs * 1.5), 10_000)\n        }\n\n        throw new Error('MiniMax OAuth timed out waiting for authorization.')\n      } finally {\n        pendingUserCode = null\n        pendingVerifier = null\n        pendingIntervalMs = 2000\n      }\n    },\n\n    async refreshToken(credentials) {\n      if (!credentials.refreshToken) {\n        return credentials\n      }\n\n      const response = await fetch(`${config.baseUrl}/oauth/token`, {\n        method: 'POST',\n        headers: {\n          Accept: 'application/json',\n          'Content-Type': 'application/x-www-form-urlencoded',\n        },","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/main/oauth/providers/minimax.ts#L170-L206","documentation":"Thrown when MiniMax's waitForToken() polling loop exhausts its 10-minute deadline without an access_token and without a terminal error from getMiniMaxErrorMessage. The finally block clears pendingUserCode, pendingVerifier, and resets pendingIntervalMs to 2000, so the flow cannot resume — startDeviceFlow must be called again.","triggerScenarios":"User never completed authorization at the verification_uri within 10 minutes; user completed it but MiniMax kept returning status==='pending' past the deadline due to backend lag; polling interval backoff (intervalMs * 1.5 capped at 10s) stretched cycles so far that too few requests fit in the window.","commonSituations":"Backgrounded app; user distracted; slow MiniMax backend keeping responses pending longer than expected; the exponential-ish backoff (1.5x, cap 10s) causing the loop to under-poll.","solutions":["Catch the timeout and restart the flow via startDeviceFlow() for a fresh user_code.","Surface 'Authorization timed out — please try again' to the user.","If the backoff cap of 10s is starving the window, lower it so more polls fit before the 10-minute deadline."],"exampleFix":"// before\nconst creds = await provider.waitForToken(signal)\n\n// after\ntry {\n  return await provider.waitForToken(signal)\n} catch (e) {\n  if (/timed out/i.test(String(e))) {\n    const fresh = await provider.startDeviceFlow()\n    throw new ReauthRequiredError(fresh)\n  }\n  throw e\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isMiniMaxTimeout(e: unknown): boolean {\n  return e instanceof Error && /MiniMax OAuth timed out/i.test(e.message)\n}","tryCatchPattern":"try {\n  return await provider.waitForToken(signal)\n} catch (e) {\n  if (isMiniMaxTimeout(e)) {\n  const fresh = await provider.startDeviceFlow()\n  throw new ReauthRequiredError(fresh)\n  }\n  throw e\n}","preventionTips":["Show the user a countdown tied to the 10-minute deadline.","Restart startDeviceFlow() on timeout rather than leaving the user in a stuck state.","If chronic, reduce the polling backoff cap (currently 10s) so more polls fit before the deadline."],"tags":["oauth","timeout","minimax","device-flow"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}