MCPcopy
hub / github.com/codeaashu/claude-code / checkQuotaStatus

Function checkQuotaStatus

src/services/claudeAiLimits.ts:220–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218}
219
220export async function checkQuotaStatus(): Promise<void> {
221 // Skip network requests if nonessential traffic is disabled
222 if (isEssentialTrafficOnly()) {
223 return
224 }
225
226 // Check if we should process rate limits (real subscriber or mock testing)
227 if (!shouldProcessRateLimits(isClaudeAISubscriber())) {
228 return
229 }
230
231 // In non-interactive mode (-p), the real query follows immediately and
232 // extractQuotaStatusFromHeaders() will update limits from its response
233 // headers (claude.ts), so skip this pre-check API call.
234 if (getIsNonInteractiveSession()) {
235 return
236 }
237
238 try {
239 // Make a minimal request to check quota
240 const raw = await makeTestQuery()
241
242 // Update limits based on the response
243 extractQuotaStatusFromHeaders(raw.headers)
244 } catch (error) {
245 if (error instanceof APIError) {
246 extractQuotaStatusFromError(error)
247 }
248 }
249}
250
251/**
252 * Check if early warning should be triggered based on surpassed-threshold header.

Callers 1

runFunction · 0.85

Calls 7

isEssentialTrafficOnlyFunction · 0.85
shouldProcessRateLimitsFunction · 0.85
makeTestQueryFunction · 0.85
isClaudeAISubscriberFunction · 0.50

Tested by

no test coverage detected