fix: resolve /pricing hydration mismatch for OAuth redirects and non-en-US locales #SUPERLOG - #417
Open
superlog-app[bot] wants to merge 1 commit into
Open
fix: resolve /pricing hydration mismatch for OAuth redirects and non-en-US locales #SUPERLOG#417superlog-app[bot] wants to merge 1 commit into
superlog-app[bot] wants to merge 1 commit into
Conversation
…en-US locales #SUPERLOG Delivery-Id: 1512dd000c228aedef6cade43c6f46516f719d81621751c6660fefbc6fcadf92 Delivery-Base: main
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.
Summary
Users arriving at
/pricingvia an OAuth redirect (URL hash contains#sso-callbackor#verify) or with a non-en-US browser locale see React error #418 — the pricing page hydrates with a tree that doesn't match the pre-rendered server HTML, so React regenerates the whole tree on the client and emits the error.Root cause
The
/pricingroute is pre-rendered at build time usingrenderToStringand served as static HTML. When the browser loads the page,main.tsxcallshydrateRootbecause the root element already contains pre-rendered content.The
Pricingcomponent had auseStatelazy initializer that branched ontypeof window === "undefined"— the classic SSR/client mismatch pattern React's own docs flag as a cause of error #418:windowisundefined→ returnsnull→ no<AuthModal>in the rendered tree.windowis defined → readswindow.location.hash→ returns"sign-in"if the hash includessso-callbackorverify(OAuth redirect landing) →<AuthModal>is included → structural divergence.Additionally, three
ScaleSliderinstances usedn.toLocaleString()(no locale argument) for the spans/logs/metrics value readout. The Node.js prerender environment formats numbers using its default locale (en-US), but a browser with a different locale (e.g., German) produces different digit separators ("2.000.000"vs"2,000,000"), causing a text-node mismatch for every non-en-US visitor.Remediation
useStateinitializer: replaced withuseState<AuthMode>(null)(alwaysnull, matching SSR) and auseEffectthat reads the hash after hydration and callssetAuthMode("sign-in")when needed. The modal still opens for OAuth redirect users — just after the first paint rather than on the initial render, which is imperceptible.toLocaleString(): pinned to"en-US"so the prerender and every browser produce identical strings regardless of system locale.Incident: moonlit-tapir
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Fixes hydration mismatch on
/pricingfor OAuth redirect landings and non‑en-US locales, eliminating React hydration errors and flicker.authModetonulland set it in auseEffectafter hydration based onwindow.location.hash(#sso-callback,#verify) to avoid SSR/client divergence.n.toLocaleString("en-US")in estimators so prerendered HTML matches all browsers.Written for commit c3dc703. Summary will update on new commits.