Skip to content

perf(start): compact deferred hydration private state - #7980

Merged
Sheraff merged 11 commits into
mainfrom
codex/solid-hydration-private-state
Aug 7, 2026
Merged

perf(start): compact deferred hydration private state#7980
Sheraff merged 11 commits into
mainfrom
codex/solid-hydration-private-state

Conversation

@Sheraff

@SheraffSheraff commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • shorten descriptive, module-private prefetch-controller keys in Solid's generic hydrator
  • replace two one-field closure state wrappers with named locals while preserving synchronous-cleanup behavior
  • store private visible-observer registry entries as labeled tuples, destructured immediately at use sites
  • add focused lifecycle coverage for synchronous completion, races, cleanup-once behavior, observer sharing, teardown, and recreation

Public APIs and declaration-facing types are unchanged. The controller keys are Solid-only; the representation changes in Start client core retain the same React and Solid behavior.

Bundle impact

ScenarioRawInitial gzipGzipBrotli
solid-start.deferred-hydration-361 B0 B-55 B-119 B

The other 16 bundle scenarios are byte-identical. Each production hunk independently improves raw and gzip size; the composed result was remeasured in the full matrix.

Validation

  • Start client core: 86 unit tests passed; type suite passed on TS 5.6 through 7.0; ESLint has 0 errors
  • Solid Start client: 8 unit tests passed; type suite passed on TS 5.6 through 7.0; ESLint passed
  • deferred-hydration e2e: 45 tests passed across Vite SSR, Rsbuild SSR, and Vite
  • full 17-scenario bundle matrix passed
  • five independent review passes approved semantics, observer lifecycle, attribution, publishability, and maintainability

Full attribution and validation details are in RESULT-optimization-solid-hydration-private-state.md.

Summary by CodeRabbit

  • Bug Fixes
    • Improved hydration prefetch handling when operations complete immediately or are interrupted.
    • Prevented hydration strategies from starting after cancellation.
    • Improved cleanup reliability to avoid repeated or incomplete resource disposal.
    • Preserved consistent visible-content hydration behavior when multiple elements are observed or cleaned up.
  • Tests
    • Added coverage for hydration timing, cancellation, cleanup, visibility tracking, and observer lifecycle scenarios.

@coderabbitai

coderabbitaiBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c0a5b27-bb9e-48a3-b855-7589da7f083e

📥 Commits

Reviewing files that changed from the base of the PR and between 222834d and 6985f84.

📒 Files selected for processing (1)
  • .changeset/shaky-berries-admire.md

📝 Walkthrough

Walkthrough

The changes update hydration prefetch cleanup handling, refactor visible observer registry entries into tuples, rename Solid hydration controller fields, and add tests for synchronous completion, races, aborts, observer sharing, and cleanup.

Changes

Hydration prefetch maintenance

Layer / File(s)Summary
Prefetch settlement and cleanup
packages/start-client-core/src/hydration/runtime.ts, packages/start-client-core/tests/hydration-runtime.test.ts, .changeset/shaky-berries-admire.md
The runtime stores disposal state directly, runs cleanup after synchronous completion, ignores repeated completion, and handles abort races and already-aborted signals. Tests cover these behaviors. The changeset records patch releases for both affected packages.
Visible observer registry
packages/start-client-core/src/hydration/visible.ts, packages/start-client-core/tests/hydration-visible.test.ts
Visible observer entries use [observer, elements] tuples. Tests cover shared observers, callback removal, disconnection, and observer replacement.
Solid hydration controller alignment
packages/solid-start-client/src/GenericHydrate.tsx
Hydration-prefetch logic uses the renamed abort, listeners, requested, and resolvePending controller fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 40.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly and concisely describes the main change: reducing private deferred-hydration state.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/solid-hydration-private-state

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloudBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 40f9baa

CommandStatusDurationResult
nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded17m 54sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 56sView ↗

☁️ Nx Cloud last updated this comment at 2026-08-07 14:08:19 UTC

@github-actions

github-actionsBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 12 bumped as dependents.

🟩 Patch bumps

PackageVersionReason
@tanstack/solid-start-client1.168.20 → 1.168.21Changeset
@tanstack/start-client-core1.170.18 → 1.170.19Changeset
@tanstack/react-start1.168.39 → 1.168.40Dependent
@tanstack/react-start-client1.168.20 → 1.168.21Dependent
@tanstack/react-start-rsc0.1.38 → 0.1.39Dependent
@tanstack/react-start-server1.167.27 → 1.167.28Dependent
@tanstack/solid-start1.168.38 → 1.168.39Dependent
@tanstack/solid-start-server1.167.27 → 1.167.28Dependent
@tanstack/start-plugin-core1.171.30 → 1.171.31Dependent
@tanstack/start-server-core1.169.22 → 1.169.23Dependent
@tanstack/start-static-server-functions1.167.23 → 1.167.24Dependent
@tanstack/vue-start1.168.37 → 1.168.38Dependent
@tanstack/vue-start-client1.167.23 → 1.167.24Dependent
@tanstack/vue-start-server1.167.27 → 1.167.28Dependent

@github-actions

github-actionsBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: a980dd360583
  • Measured at: 2026-08-07T13:51:36.652Z
  • Baseline source: history:995bd97a9f6c
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

ScenarioCurrent (gzip)Delta vs baselineInitial gzipRawBrotliTrend
react-start.minimal100.39 KiB-8 B (-0.01%)100.25 KiB310.86 KiB87.16 KiB█▂▂▂▂▁▁▁▁▁▁
react-start.deferred-hydration101.13 KiB-9 B (-0.01%)100.28 KiB312.23 KiB87.87 KiB█▂▂▂▂▁▁▁▁▁▁
react-start.full103.75 KiB-3 B (-0.00%)103.61 KiB320.81 KiB90.16 KiB█▂▂▂▂▁▁▁▁▁▁
react-start.rsbuild.minimal99.98 KiB-8 B (-0.01%)99.81 KiB315.35 KiB86.25 KiB▁████▃▃▃▄▄▄
react-start.rsbuild.minimal-iife100.39 KiB-9 B (-0.01%)100.22 KiB316.28 KiB86.60 KiB▁████▃▃▃▄▄▄
react-start.rsbuild.full103.28 KiB-11 B (-0.01%)103.11 KiB325.44 KiB88.92 KiB▁██▇█▃▃▃▄▄▃
solid-start.minimal47.96 KiB-5 B (-0.01%)47.83 KiB140.63 KiB42.69 KiB█▂▂▂▂▁▁▁▁▁▁
solid-start.deferred-hydration51.17 KiB-65 B (-0.12%)47.89 KiB148.31 KiB45.63 KiB█▂▂▂▂▁▁▁▁▁▁▁
solid-start.full53.23 KiB-8 B (-0.01%)53.11 KiB156.35 KiB47.32 KiB█▂▂▂▂▁▁▁▁▁▁
vue-start.minimal68.64 KiB-5 B (-0.01%)68.51 KiB193.40 KiB61.10 KiB█▃▃▂▂▁▁▁▁▁▁
vue-start.full72.65 KiB-4 B (-0.01%)72.52 KiB205.90 KiB64.57 KiB█▂▂▂▂▁▁▁▁▁▁

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-newBot commented Aug 6, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7980

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7980

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7980

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7980

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7980

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7980

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7980

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7980

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7980

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7980

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7980

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7980

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7980

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7980

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7980

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7980

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7980

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7980

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7980

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7980

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7980

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7980

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7980

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7980

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7980

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7980

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7980

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7980

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7980

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7980

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7980

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7980

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7980

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7980

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7980

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7980

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7980

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7980

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7980

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7980

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7980

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7980

commit: 2dbe700

@codspeed-hq

codspeed-hqBot commented Aug 6, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 1.89%

⚠️Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
❌ 7 (👁 1) regressed benchmarks
✅ 169 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

ModeBenchmarkBASEHEADEfficiency
Memorymem client unique-location-churn (solid)341.4 KB563.4 KB-39.4%
Memorymem server serialization-payload (react)3.2 MB3.5 MB-7.31%
Memorymem server error-paths redirect (react)208.4 KB223.1 KB-6.6%
Memorymem client preload-churn (vue)737 KB769.2 KB-4.19%
Memorymem server error-paths not-found (react)250.3 KB261 KB-4.1%
Memorymem client loader-data-retention (solid)148.5 KB154.4 KB-3.8%
Memorymem server error-paths redirect (vue)500.2 KB294 KB+70.15%
Memorymem client navigation-churn (vue)1.3 MB1.2 MB+5.1%
Simulationssr control-flow unmatched 404 (react)66.1 ms64 ms+3.28%
Memorymem server error-paths not-found (vue)329.6 KB319.4 KB+3.21%
👁Simulationssr request loop (solid)145.5 ms158.7 ms-8.31%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex/solid-hydration-private-state (2dbe700) with main (2fbc99f)

Open in CodSpeed

@Sheraff
Sheraff marked this pull request as ready for review August 6, 2026 07:28

@nx-cloudnx-cloudBot 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.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@Sheraff
Sheraff merged commit 6bede65 into mainAug 7, 2026
25 of 26 checks passed
@Sheraff
Sheraff deleted the codex/solid-hydration-private-state branch August 7, 2026 15:30
@github-actionsgithub-actionsBot mentioned this pull request Aug 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Sheraff