Repository navigation
fix(frontend): full page load for the sign-in redirect, ending hydration errors (#133) - #136
Merged
Merged
Conversation
…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
This was referenced Oct 28, 2026
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.
Refs #133.
Cause
/and/auditsit behindrequireSession, which runs inbeforeLoadand throws a client-sideredirectto/authwhen 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 withCannot read properties of undefined (reading 'routeId')inMatch.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-router1.170.46 is the latest release, so upgrading doesn't fix this.Change
requireSessionnow redirects withreloadDocument: true, so the browser loads/authas 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:/→/auth/audit→/auth/auth/("CSV Migrator")/audit("Import history")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