fix(tradein): RouteGuard prod 401 → session-expired screen, stop re-subscribe storm (#800) #896
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#896
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/800-routeguard-401-session-screen"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause
TanStack Query's
staleTime: Infinityapplies only to successful queries — errored queries are always stale. WhenuseMereturns 401, every new observer subscription triggers a refetch (onSubscribe → executeFetch), regardless ofretry: false.RouteGuard was mounting
<>{children}</>on 401, causing the entire page subtree to continuously re-subscribe → 616+ identical requests to/meand/quotain 15s (confirmed by design-loop Playwright repro, comment #7506 on #800).This is NOT a retry issue —
retry: falsewas already set. It's a subscribe-on-stale-error loop.Fix
On 401 in production,
RouteGuardnow renders<NoAccessScreen variant="session" />instead of mounting the app children:In development (
NODE_ENV !== "production"), the passthrough is preserved —next devwithout Caddy basic_auth still works normally.Changes
RouteGuard.tsx: 401 branch → dev passthrough / prod session screenNoAccessScreen.tsx: add"session"variant (title + subtitle)DoD verification
<NoAccessScreen variant="session" />рендерится, subtree не монтируется, цикл не возникает.NODE_ENV !== "production") → children монтируются как раньше.npx tsc --noEmit— clean.NoAccessScreenпринимаетvariant="session"без TS-ошибок.Refs #800.