Repository navigation
fix(dashboard): status refresh no longer stalls on another request's token mint - #2156
Conversation
…token mint The isolate-wide GitHub App token cache stored in-flight mint promises and handed them to later requests. Workers cancels a request's I/O when that request ends, so a mint started by a short request (a webhook, an internal call) could never settle, and every later status refresh that needed the same scope awaited it until the 18s deadline. Production tails show those refreshes ending at the deadline with github_auth pending, which leaves /api/status serving a stale snapshot. Share only settled tokens across requests, and deduplicate in-flight mints within one status collection, which owns their I/O. Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR shares completed GitHub App tokens globally while restricting pending token acquisition to one status collection. Example: A request strands a token mint for openclaw/clawsweeper Actions reads before another status refresh begins.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: main still shares pending token mints across requests, and this focused repair addresses a credible cause of stale dashboard status without a definite introduced correctness defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe dashboard Worker authenticates server-side GitHub reads, collects workflow and queue telemetry, and returns sanitized cached snapshots through /api/status. flowchart LR
A[Dashboard poll] --> B[Status collection]
B --> C[Collection token mints]
C --> D[GitHub App API]
D --> E[Completed token cache]
E --> F[GitHub telemetry reads]
F --> G[Public status snapshot]
Technical reviewBest possible solution: Keep completed-token reuse and scope enforcement in the existing authentication owner, with pending acquisition owned by each status collection. Do we have a high-confidence way to reproduce the issue? Main demonstrably reuses an indefinitely pending mint, and the report supplies matching github_auth deadline logs; the Workers request-cancellation trigger was not independently reproduced. Is this the best way to solve the issue? The patch uses the existing collection lifetime and token-scope owner, removing the persistent pending-promise dependency without adding a parallel authentication path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 49ffa8bdf0a0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 5, 2026, 12:58 AM ET / 05:58 UTC. |
Problem
/api/statuskeeps serving a stale snapshot. #2154 removed the request that timed out, but on 2026-11-05 production refreshes still ended at the 18sSTATUS_REFRESH_TIMEOUT_MSdeadline.wrangler tailonclawsweeper-statuswhile I polled/api/status:An earlier deadline in the same session also logged the Workers warning "A promise was resolved or rejected from a different request context … Continuations for that request … have been canceled." The same refresh path finishes in 7–9s locally against live GitHub.
Cause
githubAppTokenCacheis isolate-wide and stored in-flight mint promises ({ token: "", promise }), and any later request reused them. Workers cancels a request's I/O when that request ends. If a short request (a webhook, an internal call) starts a mint and finishes first, the mint never settles. Every later status refresh needing that scope then awaits it until the deadline. The entry is never removed either: the expiry sweep skippedpromiseentries, and only a rejection deleted them. So the isolate stays stale until it's recycled.Fix
StatusCollection, which owns their I/O, so a single refresh's fan-out still mints once per scope.Tests
a token mint stranded by another request cannot stall later readsfails onmain("later read stalled") and passes here.status timeout does not cancel shared GitHub App token acquisitionused to assert that a second request reused the status refresh's in-flight mint. That's exactly the sharing that strands in Workers, and Node's test runner can't model request-scoped I/O cancellation. It now asserts that the other reader gets its own token without waiting on the stalled mint, and that a later status reuses the settled token.test/dashboard-*.test.tsandtest/github-etag-read-broker.test.ts: 856/856 pass, run twice.lint:dashboard,lint:scripts, dashboardtscandoxfmtare clean.After merge and deploy, I'll check that
/api/statusregenerates within its 60s TTL and that the tail stops logginggithub_authat the deadline.