Repository navigation
fix(quota): parse absolute ISO datetime reset timestamps in weekly quota fallback - #11353
Merged
diegosouzapw merged 1 commit intoAug 24, 2026
Conversation
diegosouzapw
merged commit Aug 24, 2026
e1c2b34
into
cheaper-inference:release/v3.8.50
3 checks passed
diegosouzapw
added a commit
that referenced
this pull request
Aug 25, 2026
…n test The #11353 regression test pins an ABSOLUTE upstream reset instant (2026-08-29 21:01:21) in its production fixture body but measured the resulting cooldown against the real wall clock. The remaining window therefore shrank every day: from 2026-08-25 it dropped under the 5-day floor the two assertions use, and past 2026-08-29 it would parse to null and collapse onto the 24h WEEKLY_QUOTA_COOLDOWN_MS default - a guaranteed future red. The shipped parser (parseIsoDateTimeResetMs / parseDayGranularityResetMs / buildWeeklyQuotaFallback / checkFallbackError) is correct: it returned the real multi-day reset, just measured from today instead of the fixtures NOW. Freeze Date at NOW via node:test mock timers in the two time-dependent cases so they assert the parser rather than the calendar. No assertion weakened, no production code touched.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…ota fallback (cheaper-inference#11353) Merged via consolidated batch validation. Fixes GLM/Z.AI weekly quota fallback: parseDayGranularityResetMs only recognized 'reset in N days', dropping the real multi-day cooldown when upstream returns a full absolute ISO datetime. Own repro test passes.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…n test The cheaper-inference#11353 regression test pins an ABSOLUTE upstream reset instant (2026-08-29 21:01:21) in its production fixture body but measured the resulting cooldown against the real wall clock. The remaining window therefore shrank every day: from 2026-08-25 it dropped under the 5-day floor the two assertions use, and past 2026-08-29 it would parse to null and collapse onto the 24h WEEKLY_QUOTA_COOLDOWN_MS default - a guaranteed future red. The shipped parser (parseIsoDateTimeResetMs / parseDayGranularityResetMs / buildWeeklyQuotaFallback / checkFallbackError) is correct: it returned the real multi-day reset, just measured from today instead of the fixtures NOW. Freeze Date at NOW via node:test mock timers in the two time-dependent cases so they assert the parser rather than the calendar. No assertion weakened, no production code touched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11352.
Parses full absolute ISO datetimes (
YYYY-MM-DD[T ]HH:MM[:SS]) inparseDayGranularityResetMs/buildWeeklyQuotaFallback, so weekly/monthly quota exhaustion signals from upstreams like Z.AI (GLM) receive the actual multi-day cooldown reported by the provider instead of falling back to the 24h default.Root Cause
buildWeeklyQuotaFallbackcalledparseDayGranularityResetMs(), which only recognizedreset in N days. When the upstream provided a full datetime such asYour limit will reset at 2026-08-29 21:01:21, parsing yieldednulland fell back toWEEKLY_QUOTA_COOLDOWN_MS = 24h. The connection was retried every 24 hours until the true weekly reset.Implementation
parseIsoDateTimeResetMsinopen-sse/services/quotaResetParsing.ts, parsingYYYY-MM-DD[T ]HH:MM[:SS]with optionalZ/±HH:MMoffset and UTC fallback for naive datetimes.parseDayGranularityResetMstoparseIsoDateTimeResetMsbeforeparseMonthDayResetMs.buildWeeklyQuotaFallbackinopen-sse/services/quotaTextCooldowns.tsto use the parsed reset duration when available.Tests & Verification
node --import tsx/esm --test tests/unit/repro-glm-iso-reset-24h-cap.test.ts(12/12 pass)node --import tsx/esm --test tests/unit/ollama-cloud-weekly-quota-cooldown-3709.test.ts(6/6 pass)