Skip to content

fix: permanent [Timeout] in extra usage widgets when no monthly limit is set#416

Open
mhriemers wants to merge 2 commits into
sirmalloc:mainfrom
mhriemers:fix/extra-usage-missing-limit-timeout
Open

fix: permanent [Timeout] in extra usage widgets when no monthly limit is set#416
mhriemers wants to merge 2 commits into
sirmalloc:mainfrom
mhriemers:fix/extra-usage-missing-limit-timeout

Conversation

@mhriemers
Copy link
Copy Markdown

Summary

Fixes #413 — accounts with extra usage enabled but no monthly limit configured (monthly_limit: null) saw the extra-usage widgets render a permanent [Timeout] even though every API fetch succeeded.

Root cause

hasRequiredUsageField() treated the absence of extraUsageLimit/extraUsageUtilization as incomplete data. For limit-less accounts those fields never appear in the API response, so:

  1. cached data (memory + file) was never accepted for widgets requiring them,
  2. the fetch loop re-fetched every cycle, and
  3. getStaleUsageOrError() surfaced the lock error as [Timeout] — indefinitely, since no amount of refetching can produce a field the account doesn't have.

Fix

Extend the existing extraUsageEnabled === false special case to any response where the extra usage state is known: once the API has reported is_enabled, absent detail fields are conclusive.

With this change the widgets render nothing for limit-less accounts (instead of a false network error), matching how other widgets handle genuinely unavailable data. #414 proposes showing used_credits for these accounts.

Testing

  • New regression test treats enabled extra usage without a monthly limit as complete for extra usage widget fields, with a fixture mirroring a real monthly_limit: null API response — fails without the fix (cache rejected, second probe re-fetches), passes with it
  • Full suite: 1394 tests pass, bun run lint clean

🤖 Generated with Claude Code

…age data

Accounts with extra usage enabled but no monthly limit configured
(monthly_limit: null) never receive extraUsageLimit/extraUsageUtilization
from the usage API. hasRequiredUsageField treated those absent fields as
incomplete data on every fetch - including successful ones - so cached
data was never accepted, the fetch loop re-fetched each cycle, and the
extra usage widgets surfaced the cached lock error as a permanent
[Timeout].

Extend the existing extraUsageEnabled === false special case to any
response where the extra usage state is known: once the API has told us
whether extra usage is enabled, absent detail fields are conclusive and
refetching cannot produce them.

Fixes sirmalloc#413

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…sirmalloc#418

Once sirmalloc#418 teaches the parser about extra_usage.currency, a fixture
carrying the field would add extraUsageCurrency to the parsed result
and break this test's expectation depending on merge order. The field
is irrelevant to what this test covers (monthly_limit: null handling).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mhriemers
Copy link
Copy Markdown
Author

Pushed a small test tweak: removed currency: 'EUR' from the new fixture so this PR and #418 stay green regardless of merge order (#418 starts parsing that field, which would have added extraUsageCurrency to the parsed result and broken this test's expectation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra usage widgets show permanent [Timeout] when account has no monthly limit set

1 participant