MCPcopy Index your code
hub / github.com/codeaashu/claude-code / checkMockFastModeRateLimit

Function checkMockFastModeRateLimit

src/services/mockRateLimits.ts:847–882  ·  view source on GitHub ↗
(
  isFastModeActive?: boolean,
)

Source from the content-addressed store, hash-verified

845}
846
847export function checkMockFastModeRateLimit(
848 isFastModeActive?: boolean,
849): MockHeaders | null {
850 if (mockFastModeRateLimitDurationMs === null) {
851 return null
852 }
853
854 // Only throw when fast mode is active
855 if (!isFastModeActive) {
856 return null
857 }
858
859 // Check if the rate limit has expired
860 if (
861 mockFastModeRateLimitExpiresAt !== null &&
862 Date.now() >= mockFastModeRateLimitExpiresAt
863 ) {
864 clearMockHeaders()
865 return null
866 }
867
868 // Set expiry on first error (not when scenario is configured)
869 if (mockFastModeRateLimitExpiresAt === null) {
870 mockFastModeRateLimitExpiresAt =
871 Date.now() + mockFastModeRateLimitDurationMs
872 }
873
874 // Compute dynamic retry-after based on remaining time
875 const remainingMs = mockFastModeRateLimitExpiresAt - Date.now()
876 const headersToSend = { ...mockHeaders }
877 headersToSend['retry-after'] = String(
878 Math.max(1, Math.ceil(remainingMs / 1000)),
879 )
880
881 return headersToSend
882}
883

Callers 1

checkMockRateLimitErrorFunction · 0.85

Calls 2

clearMockHeadersFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected