Repository navigation
fix(diagnostics): let client sessions restart after five minutes - #800
Merged
Merged
Conversation
Retired client sessions were never pruned, and the sender lease never expired while the client kept submitting every minute. After the third reload, every batch from that sender got ResourceExhausted (HTTP 429) until it stopped submitting for five minutes. Retirements now carry a timestamp and expire after a sliding five-minute window. A retired session stays ignored until its window ends. Fixes: #569 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Cause
ClientDiagnostics.submit()(apps/gateway/src/diagnostics/clients.ts) keeps the retired sessions of each sender+source channel so it can ignore replays. A third new session raisedResourceExhausted("Diagnostics session limit reached"). The comment said "twice within its five-minute lease", but:state.lastis refreshed on every batch and channels are only evicted after 300 s with no batches;retiredwas never trimmed.So after the third page reload (each reload starts a new session; desktop uses
crypto.randomUUID()), every batch from that sender got HTTP 429 (gateway-errors.tsmapsResourceExhaustedto 429). This lasted until the client stopped submitting for five minutes, and that client's diagnostics were lost. In the desktop renderer it shows up asPOST /api/diagnostics/submit 429once a minute.Fix
ResourceExhausted.#restoredcheckpoints don't useretired..catch(() => {})). The console line is the browser's own network log. With this fix a 429 is only a short, rate-limited condition, so a client backoff isn't clearly needed.docs/diagnostics.mdnow describes the restart window (in Polish).Fixes: #569 (the PR that added the session limit)
Verification
Ran locally:
bun run check:tmp ./tests/integration/diagnostics-clients.test.ts: 11 pass. The new test fails on the old code withDiagnostics session limit reachedand passes with the fix. It covers:apps/gatewaytypecheck, plus oxlint and oxfmt on the edited files.Left to CI: the full gate (gen:check, repo-wide typecheck/lint/format, all test shards, builds).
Copy audit: not applicable, no UI text changes.
🤖 Generated with Claude Code