{"record":{"id":"9616393730cab120","repo":"thedotmack/claude-mem","slug":"aborting-session-for-quota-guard-decision-reaso","errorCode":null,"errorMessage":"Aborting session for quota guard: ${decision.reason}","messagePattern":"Aborting session for quota guard: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/worker/ClaudeProvider.ts","lineNumber":354,"sourceCode":"          // session is out of usage too. set() dedupes: one event per\n          // exhausted window, not one per observer request against the wall.\n          if (globalRateLimitStore.set(info)) {\n            logger.warn('SDK', 'Subscription usage limit hit', {\n              sessionDbId: session.sessionDbId,\n              window: info.rateLimitType,\n              overageStatus: info.overageStatus,\n            });\n            captureEvent('usage_limit_hit', {\n              ...buildUsageLimitHitProps(info),\n              ide: session.platformSource,\n              provider: 'claude',\n              observed_model: session.observedModel,\n              observed_billing: session.observedBilling,\n            });\n          }\n          const decision = shouldAbortForQuota(authMethod, globalRateLimitStore);\n          if (decision.abort) {\n            logger.warn('SDK', `Aborting session for quota guard: ${decision.reason}`, {\n              sessionDbId: session.sessionDbId,\n              window: decision.window,\n              authMethod,\n            });\n            session.abortReason = `quota:${decision.window ?? 'unknown'}`;\n            try {\n              session.abortController.abort();\n            } catch {\n              // best-effort\n            }\n            break;\n          }\n        }\n\n        if (message.session_id && message.session_id !== session.memorySessionId) {\n          const previousId = session.memorySessionId;\n          session.memorySessionId = message.session_id;\n          const registeredId = this.dbManager.getSessionStore().ensureMemorySessionIdRegistered(","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/worker/ClaudeProvider.ts#L336-L372","documentation":"This warning is logged when the quota guard (shouldAbortForQuota) decides a session must be aborted because the account's usage window is exhausted for the current auth method. The session is marked with abortReason `quota:<window>` and terminated. It is the enforcement action following the usage-limit detection in the same observer flow.","triggerScenarios":"startSession observes a rejected rate-limit snapshot and shouldAbortForQuota(authMethod, globalRateLimitStore) returns decision.abort=true, meaning the auth method does not bypass quota and the store shows the window is exhausted.","commonSituations":"Subscription plan exhausted with overage disabled; using an auth method that has no quota exemption while the shared rate-limit store is tripped; starting new sessions while an existing limit window is active.","solutions":["Wait for the quota window to reset before restarting the session.","Upgrade the plan or enable overage so the guard no longer aborts.","Switch to an auth method that the quota guard permits (e.g. API billing instead of subscription) once available.","Check decision.window to know which window (e.g. five_hour vs weekly) must clear."],"exampleFix":"// before\nsession.abortReason = `quota:${decision.window ?? 'unknown'}`;\n// after (defer start until window resets)\nif (decision.abort) {\n  scheduleRetryAtWindowReset(session, decision.window);\n  return;\n}\nsession.abortReason = `quota:${decision.window ?? 'unknown'}`;","handlingStrategy":"retry","validationCode":"const decision = shouldAbortForQuota(authMethod, globalRateLimitStore);\nif (decision.abort) scheduleRestartAtWindowReset(decision.window);","typeGuard":null,"tryCatchPattern":"try {\n  await provider.startSession(session);\n} catch (e) {\n  if (String(e).includes('quota:')) retryAtWindowReset(session);\n  else throw e;\n}","preventionTips":["Track which quota window (five_hour/weekly) applies to your auth method","Avoid starting sessions right after a limit-hit event","Prefer API-key auth for high-volume automation"],"tags":["rate-limit","quota","session-abort"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}