Every signed-in page in PubTrivia needs the same two facts before it can render anything: who you are, and which venue you run. The layout needs them to draw the header. The page needs them to query. Any server action fired from that page needs them again to authorise itself.
Both facts are expensive in different ways. The first is a network round trip to an auth server. The second is up to two Postgres queries over a connection that may have just been created from cold. So both of them live in one 77 line file, and that file contains the only retry loop in the repository.
The auth call is a network call, 33 times
export const getAuthenticatedUser = cache ( async () => { const supabase = await createClient () const { data : { user }, error } = await supabase . auth . getUser () if ( error || ! user ) redirect ( ' /login ' ) return user })
Enter fullscreen mode
Exit fullscreen mode
cache is React's per-request memo, not a cross-request cache.…