Repository navigation
Fix first post-hydration update remounting the passthrough-hydrated subtree - #192
Merged
Merged
Conversation
…ubtree During passthrough hydration (the Start document-shell model), a component- descriptor return mounts through the componentSlot regime. The first post-hydration re-render re-classified the same return as the childSlot regime, and the kind flip disposed the slot — tearing down the entire adopted subtree (visible as the whole app remounting and losing state on the first router event after hydration). The return-slot regime is now sticky while the returned component identity is unchanged; identity changes and shape flips still dispose. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
trueadm
added a commit
that referenced
this pull request
Jul 19, 2026
Main's fix for the first-post-hydration-update remount (#192) makes the playground's boot-time router.load() prime unnecessary — the first hash write no longer tears down the route tree. Verified in-browser: the preview iframe survives the first replaceState and example switches across hash writes keep the original instance. Co-Authored-By: Claude Fable 5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Jul 20, 2026
…esm.sh imports (#190) * Upgrade the website playground: examples, multi-file tabs, Prettier, esm.sh imports - Examples dropdown: 14 curated workspaces covering the TSRX/TSX surface (control flow, branch-local hooks, context, portals, dynamic tags, Suspense + use(), multi-file parallel use(), transitions, ViewTransition, form actions, zustand via esm.sh, and an OctaneCompat React-host demo), each gated by a test that compiles it warning-free through the real pipeline. - Multi-file workspaces: virtual file tabs with sibling imports, per-file undo history and compiled output, and a v2 share-hash format (v1 links still decode). `.react.tsx` marks React-host files compiled with sucrase. - Third-party imports: bare specifiers rewrite to esm.sh with `?external=octane`; the sandbox bootstrap installs an import map pinning octane (and octane/react) to locally built blob modules, so bindings share the singleton runtime. The runtime now ships as a code-split JSON manifest (octane + octane/react entries over a shared core chunk) and the sandbox CSP permits exactly module loads from esm.sh, nothing else. - Format button: client-side prettier/standalone + @tsrx/prettier-plugin (vite-aliased bare `prettier` to the standalone build), repo style output. - octane/compiler: vite.js and bundler.js now import node builtins in namespace form so evaluating the compiler entry in a browser dev server (externalized node:* shims) no longer throws; no behavior change in Node. - Worked around the first-router-event-after-hydration route-tree remount (tracked separately) by priming router.load() at playground boot, and added sessionStorage own-hash trust so reloads of your own code never re-hit the shared-link consent gate. Co-Authored-By: Claude Fable 5 <[email protected]> * Address CI and review feedback: no runtime skip, call-site use() in examples - The OctaneCompat e2e no longer runtime-skips when esm.sh is unreachable (the lint gate bans skip modifiers); an up-front probe now turns an unreachable CDN into an immediate, clearly-attributed failure instead. - Bugbot: the OctaneCompat Island created its fetch promise in the parent body every render, so unrelated updates (the click counter) resuspended the @Try boundary. The Island — and both Suspense examples, which taught the same antipattern — now create the promise AT the use() call site, where octane's parallel-use memoization keys it by deps; only changed inputs refetch. Verified in-browser: island clicks keep the data visible, Refetch still refetches. - The examples dropdown's "Custom" placeholder is now a static hidden option instead of a conditional branch inside <select>, so the option list never reconciles. Co-Authored-By: Claude Fable 5 <[email protected]> * Stamp sandbox runtime errors with their run generation Bugbot: a late runtime-error from a superseded run (e.g. a timer firing after a recompile) could post after the newer run's clean render and stick in the error banner. The sandbox now stamps runtime-error messages with the originating run's generation and the parent drops any that don't match the current run; covered by a unit test driving the postMessage protocol. Co-Authored-By: Claude Fable 5 <[email protected]> * Drop the router-prime workaround now that the remount fix landed Main's fix for the first-post-hydration-update remount (#192) makes the playground's boot-time router.load() prime unnecessary — the first hash write no longer tears down the route tree. Verified in-browser: the preview iframe survives the first replaceState and example switches across hash writes keep the original instance. Co-Authored-By: Claude Fable 5 <[email protected]> * Fetch the web manifest with credentials Browsers request <link rel=manifest> anonymously by default, so on SSO-protected Vercel preview deployments the manifest fetch loses its auth cookie, gets redirected to the vercel.com login, and surfaces as a CORS error in the console on every page. crossorigin="use-credentials" makes the manifest request carry cookies; same-origin production requests are unaffected. Co-Authored-By: Claude Fable 5 <[email protected]> * Keep controlled select picks alive across the native input→change task gap A real browser pick (popup commit, keyboard typeahead) dispatches trusted `input` and `change` in SEPARATE tasks with microtask checkpoints between them. The controlled-select restore ran in that gap, snapping the selection back to the rendered value before `change` dispatched — so every controlled select's onChange read the OLD value and user picks could never commit. Synthetic events (tests, Playwright selectOption) dispatch both in one task and never hit the gap, which is how the whole suite stayed green while real users couldn't switch the playground's examples dropdown. The `input` dispatch now marks the pick in flight on the element (the same window design as checkable activation): the `change` dispatch owns the after-handlers restore, and a task fallback settles sequences whose `change` never completes (stopped propagation below the root, or a synthetic lone `input`). Regression test drives the real two-task event sequence and failed before the fix; the input-only settle test moves from the microtask to the task boundary it now guarantees. Also gives the playground's example dropdown a custom chevron with breathing room from the right edge (appearance: none + inline SVG). Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
This was referenced Jul 20, 2026
This branch was previously deployed
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.
Problem
The FIRST router event after SSR hydration (a hash
replaceState,router.navigate, orrouter.load()) remounted the entire route tree in TanStack Start apps — every component under#__appunmounted and remounted, losing all state. Subsequent events behaved correctly.Root cause
renderReturnedValue's slot-regime choice was unstable across hydration:StartClientstampedHYDRATION_RANGE_BOUNDARY: 'passthrough',Body'sHydrationRangeOwnerstamped'owner'), any component-descriptor return routes through the componentSlot regime, soblock.slots[0]is acomponentSlotSlot. That's howBody'screateElement(HydrationRangeOwner, {}, children)— the slot owning everything inside#__app— mounts.Body,activeHydration()is null andHydrationRangeOwnerhas no$$singleRootstamp, so the same return now classifies as the childSlot regime. The kind mismatch hitdisposeReturnSlot, tearing down the whole adopted subtree and rebuilding it. Every later render is childSlot→childSlot — hence first-event-only.Fix
The return-slot regime is sticky while the returned component identity is unchanged: a slot mounted through the componentSlot route stays on it instead of being disposed for a mere kind re-classification. Identity changes and genuine shape flips (different component, null, array, portal, text) still dispose, preserving remount semantics. One extra short-circuited comparison on a cold path; no new state.
Tests
packages/octane/tests/hydration/post-hydration-update.test.ts+_fixtures/match-shape.tsrx: a router-Match-shaped wrapper chain and a Start-shaped document-shell scenario (passthrough root → transparent layers →Html/Bodyshell → range owner → provider/boundary chain), driven by auseSyncExternalStorereset key. Pre-fix, the Start-shaped scenario failed with['mount:inner', 'unmount:inner', 'mount:inner']and lost DOM identity in both the dev and prod compile projects.website/tests/ssr-hydration.e2e.test.ts: new real-browser test — after hydration, firehistory.replaceState(history.state, '', '#…'), require the router to actually process it (loadedAtbump viawindow.__TSR_ROUTER__as a positive control against a vacuous pass), and assertheader/mainDOM identity survives. Verified failing with the fix reverted.Validation
pnpm test: 1212 files / 11623 tests green (clean run on the final tree)pnpm typecheck,pnpm format:check: cleanoctanepatchResidual note: a pre-existing edge remains where a transparent return slot whose value flips shape post-hydration disposes without a whole-container sweep; this change narrows exposure (same-identity no longer disposes) but doesn't audit that path.
🤖 Generated with Claude Code
Note
Medium Risk
Touches core
renderReturnedValueslot-regime logic on the hydration boundary; the fix is narrow (same-component identity only) and heavily tested, but incorrect stickiness could affect remount semantics for return-slot shape changes.Overview
Fixes a first post-hydration update bug where TanStack Start (and similar passthrough-hydration shells) remounted the entire
#__appsubtree on the first router-driven re-render, wiping component state and replacing DOM nodes.In
renderReturnedValue, passthrough hydration used the componentSlot path for descriptor returns; once hydration ended, the same return was reclassified as childSlot, triggering slot disposal and a full subtree teardown. The change adds a sticky rule: an existingcomponentSlotSlotwhosecurrentCompstill matches the returned component type keeps the componentSlot route instead of flipping regimes.Adds hydration unit tests (Match-shaped wrapper chain + Start-shaped document shell) and a website e2e that fires
history.replaceStateafter load and assertsheader/mainDOM identity plus routerloadedAtprocessing. Ships an octane patch changeset.Reviewed by Cursor Bugbot for commit 53c671b. Bugbot is set up for automated code reviews on this repo. Configure here.