fix(ui): drop superseded useApiResource responses when the path changes mid-flight#7790
Conversation
…es mid-flight useApiResource had no cancellation guard, so when path changes (pagination offsets, free-text repo input, analytics window selection) an older request's response could resolve after a newer one and silently overwrite it — showing the wrong page/repo while the surrounding UI reflects the newer request. Tag each load with an incrementing request id and drop the result after the await if a newer load has superseded it. Fixes the class for every useApiResource consumer. Closes JSONbored#7785
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-21 13:04:19 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
useApiResource(apps/loopover-ui/src/lib/api/use-api-resource.ts) had no cancellation guard when itspathdependency changed:loadawaitsapiFetchand thensetStateunconditionally, so an older request could resolve after a newer one and silently overwrite it. Reachable via pagination (dead-letter-queue-paneloffset), free-text input (owner-panelrepo field), and window selection (app.analytics) — the stale response wins the race while the surrounding UI (row counts, Prev/Next, inputs) reflects the newer request.Fix: tag each load with an incrementing request id held in a ref; after the await, drop the response if a newer load has since superseded it. This is the shared hook, so the fix resolves the class for every consumer (dead-letter-queue, owner, analytics, notification-readiness, digest, maintainer, miner, commands panels, operator/index/runs routes). No behavior change for the normal single-request path;
reloadis unaffected.Tests
Adds a stale-response regression test to
use-api-resource.test.ts: two in-flight loads where the older resolves last must leave the newer page in place. Full loopover-ui suite (525 tests) green; both branches of the new guard covered.Validation
@loopover/uitypecheck, lint, prettier, and the full vitest suite (525 pass incl. the new case) green; rebased on latestmain. Zero-visual-diff (a data-race guard in a lib/api hook — no rendered-output change).Closes #7785