{"record":{"id":"887cbbc61976111b","repo":"chatboxai/chatbox","slug":"qwen-oauth-timed-out-waiting-for-authorization","errorCode":null,"errorMessage":"Qwen OAuth timed out waiting for authorization.","messagePattern":"Qwen OAuth timed out waiting for authorization\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/oauth/providers/qwen.ts","lineNumber":156,"sourceCode":"        } else {\n          const payload = (await response.json().catch(() => ({}))) as {\n            error?: string\n            error_description?: string\n          }\n\n          if (payload.error === 'authorization_pending') {\n            continue\n          }\n          if (payload.error === 'slow_down') {\n            intervalMs = Math.min(intervalMs + 2000, 10_000)\n            continue\n          }\n\n          throw new Error(`Qwen OAuth failed: ${payload.error_description || payload.error || response.statusText}`)\n        }\n      }\n\n      throw new Error('Qwen OAuth timed out waiting for authorization.')\n    } finally {\n      pendingDeviceCode = null\n      pendingVerifier = null\n      pendingIntervalMs = 2000\n    }\n  },\n\n  async refreshToken(credentials) {\n    if (!credentials.refreshToken) {\n      log.warn('[OAuth:Qwen] No refresh token available, returning existing credentials')\n      return credentials\n    }\n\n    const response = await fetch(`${QWEN_BASE_URL}/api/v1/oauth2/token`, {\n      method: 'POST',\n      headers: {\n        Accept: 'application/json',\n        'Content-Type': 'application/x-www-form-urlencoded',","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/main/oauth/providers/qwen.ts#L138-L174","documentation":"Thrown when the device-flow polling loop exits because Date.now() passed the 10-minute deadline (Date.now() < deadline became false) without ever receiving an access_token. It is a pure client-side timeout, distinct from [80] which requires the server to return an explicit error. The deadline is set at the start of authenticate() to Date.now() + 10*60*1000.","triggerScenarios":"The user never opens the verification URL, or completes verification but the poll interval (starting 2000ms, capped 10000ms after slow_down) plus each abortableSleep never lands a successful token within 600s. Also reachable if the signal is never aborted but the server only ever returns authorization_pending until the deadline.","commonSituations":"User walks away from the device-authorization prompt; user completed login on the wrong account / wrong region; network is so slow that every fetch eats the interval and the deadline elapses before enough polls; the UI that shows the verification_uri closed before the user acted.","solutions":["Treat it as user-facing: show 'Authorization timed out' and offer a 'Try again' button that calls authenticate() again for a fresh device code.","Verify the verification_uri (and user_code) were actually displayed to the user — a UI bug that never renders the prompt produces this every time.","If polls seem too infrequent, confirm pendingIntervalMs starts at 2000 and slow_down increments are honored; do not lower the cap below the server's advised interval.","Check for a hung signal — if the AbortSignal was already aborted, abortableSleep rejects and the loop never completes a real poll."],"exampleFix":"try {\n  return await qwenProvider.authenticate(signal)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Qwen OAuth timed out waiting for authorization.') {\n    // prompt user to retry; re-initiate device flow\n  }\n  throw e\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"function isQwenTimeout(e: unknown): e is Error {\n  return e instanceof Error && e.message === 'Qwen OAuth timed out waiting for authorization.'\n}","tryCatchPattern":"try { return await qwenProvider.authenticate(signal) }\ncatch (e) { if (isQwenTimeout(e)) { ui.notify('Authorization timed out, please retry'); return qwenProvider.authenticate(signal) } throw e }","preventionTips":["Render the verification_uri immediately so the user can act within the deadline.","Wire a visible countdown to the 10-minute deadline.","Abort the signal when the user cancels, to fail fast instead of timing out."],"tags":["oauth","qwen","device-flow","timeout","typescript"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}