Repository navigation
Fix quota reset timestamp parsing for Unix seconds - #768
Merged
Merged
Conversation
luckystart79-lang
pushed a commit
to luckystart79-lang/minirouter
that referenced
this pull request
May 2, 2026
Co-authored-by: Delynn Assistant <zhen@dkzhen.org>
caothu159
pushed a commit
to diepxuan/9router
that referenced
this pull request
May 14, 2026
Co-authored-by: Delynn Assistant <zhen@dkzhen.org>
diegosouzapw
pushed a commit
to cheaper-inference/OmniRoute
that referenced
this pull request
Jun 21, 2026
`parseResetTime` in `open-sse/services/usage.ts` and `codexUsageQuotas.ts` already handled `number` reset values with the `< 1e12 ? * 1000 : value` seconds-vs-ms heuristic, but for `string` inputs it always called `new Date(str)`. When a provider returned the reset timestamp as a numeric string (e.g. `"1700000000"`), `new Date(str)` returned Invalid Date, the try/catch swallowed it, and the function returned `null` — the reset window was silently dropped from quota snapshots. Numeric strings (`/^\d+$/`) are now detected and treated as Unix timestamps with the same seconds-vs-ms heuristic. ISO/parseable strings are untouched. Applied symmetrically in both parsers. TDD: 2 failing tests added in `tests/unit/usage-utils.test.ts` for the seconds-string and ms-string cases; both green after the fix (47/47 in file, 27/27 in adjacent usage/quota tests). Inspired-by: decolua/9router#768 Co-authored-by: Zhen <zhen@dkzhen.org>
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 quota reset timestamp parsing so provider APIs that return Unix timestamps in seconds, milliseconds, or numeric strings are handled correctly.
Why
Previously numeric reset values were always passed directly to
new Date(...), which treats numbers as milliseconds. If a provider returns Unix seconds, the UI can display an incorrect 1970-era reset date.Changes
Testing
Not run; small parsing-only change.