Title: fix(site): resolve chunk error and logout navigation - #949
Open
rcjasub wants to merge 1 commit into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #848 by preventing client-side logout navigation errors, correcting an invalid directive on the /news page, and adding a recovery path for stale chunk loads after deployments.
Changes:
- Replace
next/navigationserver-onlyredirect()usage in client logout with a browser navigation (window.location.replace('/')). - Remove an incorrect
'use server'directive from the/newspage. - Add ChunkLoadError detection in the global
app/error.tsxto reload once when stale chunks are requested.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/site/src/lib/auth.test.ts | Updates logout tests to assert browser navigation via window.location.replace('/') and updated error behavior. |
| apps/site/src/lib/auth-client.ts | Replaces server-only redirect with window.location.replace('/') and returns a logout response. |
| apps/site/src/app/error.tsx | Adds ChunkLoadError detection to trigger a one-time reload using a sessionStorage guard. |
| apps/site/src/app/(unauthenticated)/[locale]/(marketing)/news/page.tsx | Removes 'use server' directive so the page remains a normal Server Component. |
Comments suppressed due to low confidence (1)
apps/site/src/app/error.tsx:23
- This is the global app error boundary (per the docstring), and it now handles chunk-loading failures in addition to auth problems. The heading "There was an error with authentication" is misleading for non-auth errors and for cases where the ChunkLoadError fallback falls through to the UI after one reload attempt.
// ChunkLoadError fires when the browser fetches a JS chunk that no longer
// exists after a new deployment. Reload once to pick up fresh chunks.
// The sessionStorage flag prevents an infinite reload loop if the error persists.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+25
| // ChunkLoadError fires when the browser fetches a JS chunk that no longer | ||
| // exists after a new deployment. Reload once to pick up fresh chunks. | ||
| // The sessionStorage flag prevents an infinite reload loop if the error persists. | ||
| if ( | ||
| error.name === 'ChunkLoadError' || |
Comment on lines
+92
to
+93
| window.location.replace('/'); | ||
| return { data: {}, responseType: AuthResponseTypes.Logout }; |
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.
Description
Fixes #848
Resolves two related issues reported on the
/newspage and after logout:auth-client.tswas callingredirect('/')fromnext/navigation, which is server-only. Calling it from a client context throws an unhandled error that triggers the React error boundary. Replaced withwindow.location.replace('/')which works correctly in the browser and is more appropriate for logout since it clears all client state.news/page.tsxhad a'use server'directive which marks exports as Server Actions rather than a Server Component. Removed — pages are Server Components by Next.js convention.app/error.tsxthat reloads the page once when detected. AsessionStorageflag prevents an infinite reload loop if the error persists.Checklist