Skip to content

Title: fix(site): resolve chunk error and logout navigation - #949

Open
rcjasub wants to merge 1 commit into
mainfrom
fix/chunk-error-news-logout
Open

Title: fix(site): resolve chunk error and logout navigation#949
rcjasub wants to merge 1 commit into
mainfrom
fix/chunk-error-news-logout

Conversation

@rcjasub

@rcjasub rcjasub commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #848

Resolves two related issues reported on the /news page and after logout:

  • Logout error: auth-client.ts was calling redirect('/') from next/navigation, which is server-only. Calling it from a client context throws an unhandled error that triggers the React error boundary. Replaced with window.location.replace('/') which works correctly in the browser and is more appropriate for logout since it clears all client state.
  • Incorrect page directive: news/page.tsx had a 'use server' directive which marks exports as Server Actions rather than a Server Component. Removed — pages are Server Components by Next.js convention.
  • ChunkLoadError: After a new deployment, chunk filenames change. Clients with cached HTML fetch stale chunk URLs that 404, triggering React error fix(db): auto-update updatedAt timestamps #418. Added a ChunkLoadError check in app/error.tsx that reloads the page once when detected. A sessionStorage flag prevents an infinite reload loop if the error persists.

Checklist

  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • Any components that you've modified are accessible.
  • You've used conventional commits where appropriate

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
internal-dashboard Ready Ready Preview, Comment Jun 18, 2026 4:19am
nightcrawler Ready Ready Preview, Comment Jun 18, 2026 4:19am

@Orlando275
Orlando275 marked this pull request as ready for review July 28, 2026 23:20
Copilot AI review requested due to automatic review settings July 28, 2026 23:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/navigation server-only redirect() usage in client logout with a browser navigation (window.location.replace('/')).
  • Remove an incorrect 'use server' directive from the /news page.
  • Add ChunkLoadError detection in the global app/error.tsx to 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 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Chunk error after logging out and/or navigating to /news page

2 participants