Skip to content

fix(frontend): full page load for the sign-in redirect, ending hydration errors (#133) - #136

Merged
amar-python merged 1 commit into
mainfrom
fix/133-hydration
Oct 28, 2026
Merged

amar-python merged 1 commit into
mainfrom
fix/133-hydration

Conversation

@amar-python

Copy link
Copy Markdown
Owner

Refs #133.

Cause

/ and /audit sit behind requireSession, which runs in beforeLoad and throws a client-side redirect to /auth when there's no session. On a first page load the redirect fires while React is still hydrating. The router then renders a match that no longer exists, which errors with Cannot read properties of undefined (reading 'routeId') in Match.js. React logs #520 and #422, then recovers by rendering on the client. The dev build gives the same errors with full messages. @tanstack/react-router 1.170.46 is the latest release, so upgrading doesn't fix this.

Change

requireSession now redirects with reloadDocument: true, so the browser loads /auth as a fresh page instead of switching routes mid-hydration. The cost is one extra page load, and only for a signed-out visitor. Signed-in navigation is unchanged.

The unit test now asserts reloadDocument. It fails without the change: I checked, and it reported 1 failed, 14 passed.

Verification

Production build (NITRO_PRESET=node-server) served by Node, loaded in Chromium. The API is stubbed, and the console errors are counted on each page load:

Page Before (main) After
Signed out / → /auth 4 errors 0
Signed out /audit → /auth 4 errors 0
Signed out /auth 0 0
Signed in / ("CSV Migrator") 0 0
Signed in /audit ("Import history") 0 0

Also: vitest 12 files, 139 tests passed; tsc 0 errors; eslint 0 problems on the changed files.

#133 stays open until this is merged and the product owner confirms the browser console is clean on their machine.


Generated by Claude Code

…133)

Opening / or /audit without a session threw a client-side redirect
from beforeLoad while the first page was still hydrating. The router
then rendered a match that no longer existed ("reading 'routeId'"),
and React logged #520 and #422 before recovering. The guard now
redirects with reloadDocument, so the browser loads /auth afresh.

Production build in Chromium: 8 console errors before, 0 after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019YPoXzBSj89ZHgw7nfTmbB
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.

2 participants