Skip to content

fix: share dev and production hydration payload serialization - #1162

Merged
domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:codex/refactor-hydration-payload-serializer
Sep 19, 2026
Merged

domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:codex/refactor-hydration-payload-serializer

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Development SSR puts client-build metadata before route fields, while production puts it after them. Share script-safe route serialization so both handlers emit the same field order, defaults and escaping, with request-specific document identities preserved. Expose the shared serializer through the existing app-core HTML entry point.

Addresses the route hydration serializer finding in #967; that compound audit has other remaining work.

Validation

  • Scoped formatting and typechecks for app-core and the Vite plugin.
  • Required pnpm sync; no generated changes.
  • 36 focused route, build-metadata and production-asset tests pass using an owner-only Vitest configuration.
  • Real Vite dev/production SSR build: 7 selected integration tests pass, including route parity, global boundaries and nonce handling.
  • Regression fails before the fix when build metadata is present. Removing delimiter escaping makes all 8 new dev/production cases fail.
  • Repo-wide formatting, typecheck and full Vitest suite were not run locally; current-head CI results are recorded below.

CI

The current head 6e19dbc56d77cf8339213c63efe909e1053a04e8 merges main dc8f3cdb. The original eight-file payload diff is byte-identical after the merge. After refresh, 36 focused tests on Node 24.13.0, scoped typechecks and formatting, and pnpm sync pass. Current-head CI passed all 26 jobs on this exact head. Cursor Bugbot also passed without findings. The PR was subsequently merged as 5f4b258d80701d70f17790d14c6ac39ec9cb3d0b.

Prior head 23e4e35aa1d2a82ae903fa51ece298ab45a0254f passed Cursor Bugbot and CI run 35472520028, with all 26 jobs passing.

The first run failed TanStack Query's existing SSR error hydration case with missing QueryClient context. One failed-job retry passed on the same commit, with no source, assertion or deadline changes. The retry does not establish the underlying context failure's cause.

Risk / follow-ups

The serializer adds one temporary object per rendered route request; no component, node or signal hot path changes. Matched neutral server-bundle checks with esbuild 0.28.1 measured production +261 raw / +45 gzip / +57 Brotli bytes and dev -82 raw / -20 gzip / -22 Brotli bytes. These are focused bundle measurements, with no CPU or production performance claim.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches inline script JSON and XSS escaping on every SSR render; scope is narrow and covered by new dev/production parity tests.

Overview
Unifies how dev and production SSR build the inline #__octane_data hydration script so both paths emit the same JSON shape, field defaults, key order (including when clientBuild metadata is present), and </> escaping.

Adds shared serializeRouteData in app-core (with RouteHydrationData types), exports it from @octanejs/app-core/html, and wires dev handleRenderRoute and production createHandler through it—removing duplicated local escapeScript helpers. Adds matrix tests that dev and production responses match byte-for-byte aside from per-request documentId.

Reviewed by Cursor Bugbot for commit 6e19dbc. Bugbot is set up for automated code reviews on this repo. Configure here.

@domgan-oai
domgan-oai merged commit 5f4b258 into octanejs:main Sep 19, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant