Skip to content

fix: distinguish dormant capture updates from hydration mismatches - #1181

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fix-hydrate-capture-diagnostics-1172
Sep 20, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/fix-hydrate-capture-diagnostics-1172

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

A mounted parent update to a dormant Hydrate boundary could report attribute mismatches for valid updates, while an initial mismatch corrected before activation could disappear from diagnostics. Compare development attribute diagnostics with the initial client captures and provider values, while activating the live child with the latest captures.

Fixes #1172.

  • Preserve adopted DOM, uncontrolled input edits, focus/selection, child state, and current event/ref/effect values.
  • Preserve genuine initial attribute, class, and style diagnostics, including corrected mismatches and initial suppression semantics. Carry initial snapshots through nested dormant boundaries.
  • Collect historical attributes in disposable, isolated development scopes. Discard refs/effects and keep portals, head resources, native ownership, retries, HMR registrations, and surrounding context collectors out of that pass.
  • Emit lazy development capture witnesses for unsplit boundaries so changing only when avoids an unnecessary child render. Keep guarded or opaque template reads conservative.
  • Add owning SSR/public-consumer regressions, a parser-AST immutability control, deferred-hydration documentation, and an Octane patch changeset.

Validation

  • Hydration, SSR diagnostics, and hydration mismatch/input conformance suites in octane and octane-prod with --maxWorkers=4: 142 files, 1,786 tests passed.
  • Owning split/unsplit public-consumer regressions: 48 cases passed with literal production/development runtime and compiler modes, including the guarded-read regression. The broad run also covers the deferred-hydration suite in both projects.
  • Hydrate compiler, split AST, AST immutability, and AST emission audit: 370 tests passed.
  • Scoped tsrx-tsc typecheck for changed Octane source/tests and the new fixture; scoped formatting and git diff --check.
  • Staged-DOM static gate and its regression suite: 10 tests passed. New exemptions cover only inert diagnostic construction; unprojected source serialization and live attribute writes remain rejected.
  • Changeset/release-plan checks and pnpm sync; no additional generated changes.
  • pnpm format:check (used scoped checks locally)
  • pnpm typecheck (used scoped checks locally)
  • pnpm test (used targeted suites locally)

The unrestricted broad run hit two existing 5,000 ms SSR diagnostic deadlines. That suite passed all 12 cases in isolation, and the four-worker broad run passed all 1,786 cases without changing deadlines or assertions.

Matched nine-sample benchmarks/deferred-hydration-boundaries/run.mjs controls pass: server adoption, sidecar cleanup, unmount, and Set allocations remain 14/6,155 for 1/2,048 boundaries, exactly 3 Sets per additional boundary. Timings had substantial machine drift/noise, so no speed claim is made. The production runtime is byte-identical before identifier mangling (821,892 bytes); the fully minified envelope differs by +8 bytes/+11 gzip bytes solely from short-name assignment. The development envelope adds 5,109 bytes/1,722 gzip bytes.

Risk / follow-ups

Development activation with changed captures can evaluate the initial child render in a detached tree solely to collect attribute diagnostics. It never commits historical hook state, refs, or effects. Unavailable historical data and unsupported native computations retain ordinary checks at unvisited sites; structural recovery behavior is unchanged. Local DOM evidence uses the public SSR/compiler/runtime path in Happy DOM; no physical-device qualification was run.

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 core deferred-hydration activation and dev-only diagnostic rendering in runtime.ts; production is mostly gated, but dormant-boundary behavior and compiler dev output change.

Overview
Fixes false dev hydration warnings when a mounted parent updates a dormant Hydrate boundary, while still reporting real initial server/client attribute, class, and style mismatches—even if props are corrected before activation.

Runtime (dev): Snapshots initial boundary props, contexts, and IDs; when captures change, re-renders the initial child tree in an inert document (hydrateAttributeProbe) to baseline attributes. Live activation uses latest captures; mismatch warnings compare server HTML to that baseline, not post-update values. Side effects during the probe are fenced (signals, native reads/hooks, portals, float resources, retries, HMR, etc.).

Compiler (dev): Emits lazy CHILDREN_DIAGNOSTIC_CAPTURES witnesses on Hydrate children blocks (conservative when control flow/getters/shadows are unsafe). Unsplit boundaries can avoid rendering the child until when changes.

Docs, changeset, broad split/unsplit consumer tests, AST immutability control, and staged-DOM exemptions for the diagnostic pass.

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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 20, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 20, 2026 17:56
@domgan-oai
domgan-oai merged commit 138ec3c into octanejs:main Sep 20, 2026
50 checks passed
domgan-oai pushed a commit that referenced this pull request Sep 23, 2026
…nders (#1282)

When a mounted parent changes a dormant Hydrate boundary's captures or
provided context before activation, the server HTML predates the client's
state. Decide that by comparing the initial and current captures instead
of rendering the child with its historical props, and repair attributes,
class, style and text without mismatch diagnostics in dev and prod.

Removes the development-only historical attribute probe (#1181) and the
native-signal isolation built on it (#1238), which re-ran component
bodies, state initializers, memo factories and getSnapshot with stale
props.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Hydrate emits dev attribute mismatch diagnostics after legitimate updates to dormant captures

1 participant