Conversation
getSession() threw an unhandled ZodError when the session cookie was missing/expired, because the middleware refreshed the JWT but never forwarded the new cookie to the current request, so downstream Server Components still parsed the stale one. Forward the revalidated cookies into the request in middleware, make getSession() fail gracefully to null instead of throwing, and redirect to login in the dashboard layout only if revalidation truly failed. Fixes FIXR-49 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
apps/server/src/modules/account/repositories/index.ts had unresolved <<<<<<< HEAD / ======= / >>>>>>> markers left over from an earlier merge, silently committed to develop. Resolved onto the Cached/ InvalidateCache infra (the current caching approach used by every other repository), migrating updateAvatarUrl off the now-deleted core/lib/cache helpers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumo
getSession(apps/web/lib/auth/utils.ts) chamavauserJWT.parsesem tratamento, então um cookie de sessão ausente/expirado lançava umZodErrornão tratado e derrubava a página.apps/web/middleware.ts) já revalidava o JWT via/auth/tokenquando expirado, mas só anexava o cookie renovado na resposta — nunca repassava para a request atual. Por isso, o Server Component (layout.tsx) ainda lia o cookie antigo/expirado na mesma passagem e quebrava.NextResponse.next({ request })), garantindo que a sessão revalidada seja usada na mesma renderização em vez de crashar.getSessionagora usasafeParsee retornanullem vez de lançar, igual ao padrão já usado emgetClientSession.apps/web/app/(protected)/dashboard/[subdomain]/layout.tsx) redireciona para/auth/loginapenas se a revalidação realmente falhar (sessão nula após a tentativa do middleware).<<<<<<< HEAD/>>>>>>>) já commitado emapps/server/src/modules/account/repositories/index.ts, migrandoupdateAvatarUrlpara oInvalidateCache(infra de cache atual), já que os helpers antigos decore/lib/cachenão existem mais.Plano de teste
tsc --noEmit(web e server)biome checknos arquivos alterados/auth/loginFixes FIXR-49
🤖 Generated with Claude Code