Repository navigation
Closed
Labels
Description
Every profile screen fires its API reads before the Supabase access token is usable. The requests 401, and nothing retries them once the session refreshes, so the editors render permanently empty even though the data exists server-side.
Evidence
Single load of /profile/resume (signed in, seeded user [email protected]):
GET /v1/profiles/general -> 401
GET /v1/profiles/employment -> 401
GET /v1/profiles/slug/history -> 401
GET /v1/profiles/import/data -> 401
GET /v1/resume/has-uploaded -> 401
GET /v1/profiles/widgets/general-info -> 401
Only prerequisites/check, auth/roles and notifications/unread-count were retried after the refresh. The rest stayed failed for the life of the page.
The same endpoint with the same session, called by hand from the page:
{"first_name":"Zach","last_name":"Servideo","email":"[email protected]",
"phone":"+1 (424) 280-2876",
"address":{"street":"10 Central Street","city":"Ipswich","state":"MA","zip":"01938"}}The rendered form at that moment:
[{"ph":"First name","v":""},{"ph":"Last name","v":""},{"ph":"Phone number","v":""},
{"ph":"Email address","v":""},{"ph":"Street address","v":""},{"ph":"City","v":""}]The same load also issued 9 POST /auth/v1/token?grant_type=refresh_token for 20 API calls — there is no single-flight around the refresh.
Root cause
Two independent gaps:
- packages/scf-core/utils/jobs-sdk-context.tsx:54 — the recovery invalidation only fires on the
isLoadingtrue→false transition (wasLoadingRef). A token that expires while the tab is open never triggers it. - packages/scf-core/utils/jobs-sdk-context.tsx:59 — the
sdkQueryKeyPrefixesallow-list has 10 entries, but scf-core registers 30+ query-key roots. Missing:resume,idVerification,user-profiles,communities,workLogs,connections,follows,tasks,punchlists,scheduling,analytics,personality-assessment,office,workers,map,inquiries,ccpa,oauth, and['scaffald','skills',…](onlysecondvalues in the list match, andskillsis not one). - packages/scf-core/provider/react-query/QueryProvider.tsx:12 —
retry: 2retries a 401 twice against the same stale client, burning the retry budget before the refresh lands.
Acceptance
- A 401 from the SDK triggers exactly one token refresh (single-flight) and one retry with the new token.
- Query invalidation fires on every
session.access_tokenchange, not only the first load. - The prefix allow-list is removed in favour of invalidating all SDK-backed queries (or is derived from a single exported registry so it cannot drift).
- Reloading
/profile/resumewith an expired token populates General Information, Employment Preferences, and the vanity-URL field on the first render, with zero 401s in the network log. - A regression test asserts no more than one refresh POST per page load.
Activity
thinkclay commentedon Aug 12, 2026
Part of the profile-building audit rollup: #594
fix(auth): stop profile screens loading empty after a 401 (#579) (#595)