Manager page can hang on a skeleton or flash for non-managers #42

Open
opened 2026-10-03 19:44:38 +00:00 by jalenluorion · 0 comments
Member

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

  1. Signed in, open DevTools > Network, right-click get_role and choose "Block request URL", then reload /manager: the skeleton never goes away.
  2. Unblock it. As a normal user, open /manager: the sidebar and dashboard flash, and organizations/get_all_orgs is 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: fetchUserRole has no try/catch, so a failure leaves userRole null and throws an unhandled rejection.
  • web/src/app/manager/page.tsx: if (!userRole) return <ManagerPageSkeleton /> lets "user" through, so ManagerSidebar mounts and calls getAllOrganizations().
  • web/src/app/manager/page.tsx and web/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; consider router.replace.
  • "Non-managers who open /manager land on a broken 404 page" also edits redirect.ts; coordinate.

Done when

  • A failed role request shows an error and a working retry.
  • A normal user never sees manager content, and no organizations request is sent.
  • The redirect runs once.
  • web/src/__tests__/manager.page.test.tsx covers the failed request and the "user" case.
**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** 1. Signed in, open DevTools > Network, right-click `get_role` and choose "Block request URL", then reload /manager: the skeleton never goes away. 2. Unblock it. As a normal user, open /manager: the sidebar and dashboard flash, and `organizations/get_all_orgs` is 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`: `fetchUserRole` has no try/catch, so a failure leaves `userRole` null and throws an unhandled rejection. - `web/src/app/manager/page.tsx`: `if (!userRole) return <ManagerPageSkeleton />` lets `"user"` through, so `ManagerSidebar` mounts and calls `getAllOrganizations()`. - `web/src/app/manager/page.tsx` and `web/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; consider `router.replace`. - "Non-managers who open /manager land on a broken 404 page" also edits `redirect.ts`; coordinate. **Done when** - [ ] A failed role request shows an error and a working retry. - [ ] A normal user never sees manager content, and no organizations request is sent. - [ ] The redirect runs once. - [ ] `web/src/__tests__/manager.page.test.tsx` covers the failed request and the "user" case.
jalenluorion added this to the Phase 1 milestone 2026-10-03 19:44:38 +00:00
jalenluorion added this to the CMUCal project 2026-10-03 19:45:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/cal#42
No description provided.