Manager page can hang on a skeleton or flash for non-managers #42
Labels
No labels
bug
chore
data
feature
frontend
good first issue
intermediate
needs/docs
needs/research
needs/upstream
type/bug
type/external
type/feature
type/refactor
urgency
high
urgency
immediate
urgency
low
urgency
medium
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ScottyLabs/cal#42
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
What's wrong
Three problems on /manager: if the role request fails, the loading skeleton stays forever; users who are not managers or admins briefly see the full manager page, which also loads every organization; and the redirect can fire repeatedly.
How to reproduce
get_roleand choose "Block request URL", then reload /manager: the skeleton never goes away.organizations/get_all_orgsis requested before the redirect.Expected
A failed role check shows an error with a retry button. Non-managers see only the skeleton until they are redirected, once, and no manager data is requested.
Where to look
web/src/app/manager/page.tsx:fetchUserRolehas no try/catch, so a failure leavesuserRolenull and throws an unhandled rejection.web/src/app/manager/page.tsx:if (!userRole) return <ManagerPageSkeleton />lets"user"through, soManagerSidebarmounts and callsgetAllOrganizations().web/src/app/manager/page.tsxandweb/src/app/utils/redirect.ts:["manager", "admin"]is a new array every render and is a dependency of the redirect effect, so the effect reruns on every render. Hoist it to a module constant; considerrouter.replace.redirect.ts; coordinate.Done when
web/src/__tests__/manager.page.test.tsxcovers the failed request and the "user" case.