Skip to content

Commit 7591eff

Browse files
fix: preserve provider ancestry during hydration recovery (#40)
* fix: preserve provider ancestry during hydration recovery * fix: retain the document shell when hydration recovery fails
1 parent 1f95ec9 commit 7591eff

8 files changed

Lines changed: 3553 additions & 57 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/redact': patch
3+
---
4+
5+
Keep component and context provider ancestry when recovering from a hydration mismatch. Document recovery preserves the existing shell, root renders still update the full app, and abandoned effects are cleaned up.

‎benchmarks/HYDRATION_RECOVERY.md‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Hydration recovery size review
2+
3+
Document mismatch recovery keeps the original component and provider tree.
4+
The recovery target selector now handles local hosts, the document body and
5+
root fallback in one place. No feature is disabled or generated bundle patched.
6+
7+
Production es2022 ESM builds use the existing `measureSizes` command with
8+
esbuild 0.28.0 and Node 24.15.0. These are entry bundles retaining all exports,
9+
not a whole-site size comparison or a runtime performance result.
10+
11+
The baseline is unmodified revision `62b81c1c6e0aa38e06ad70bc72d650f739730314`,
12+
extracted and built in `/private/tmp/redact-size-baseline-Cdgx1m/package`.
13+
The corrected package is `/private/tmp/redact-hydration-reviewed-f0677f5/package`.
14+
The generated baseline and recovery records in `results/` bind every measured
15+
source and built module, the compiler version and the exact entry sizes.
16+
17+
| Built entry | Baseline gzip bytes | Recovery gzip bytes | Change |
18+
| --- | ---: | ---: | ---: |
19+
| DOM API | 25,216 | 25,252 | +36 |
20+
| DOM client | 24,960 | 24,894 | -66 |
21+
| Combined client | 28,125 | 28,061 | -64 |
22+
| Combined client, default Vite | 23,290 | 23,227 | -63 |
23+
24+
The original DOM budget is 25,246 bytes. The corrected entry exceeds it by
25+
6 bytes. The approved budget remains 25,282, leaving a 30-byte margin.
26+
Only this entry's budget changes, all other limits stay intact.
27+
This is an explicit acceptance of the measured correctness cost, not a pass
28+
under the old limit. The combined client becomes smaller, not larger.
29+
30+
PR review also caught cleanup targeting the entire document when a narrowed
31+
recovery retry throws. Cleanup now retains the same narrowed target. Its new
32+
regression fails before the fix and passes afterward, preserving the document
33+
shell and head resources. Both reset calls now pass an explicit target, so the
34+
unused default parameter is removed. This reduces the approved candidate by
35+
5 gzip bytes for the DOM API and 3 for the combined client, without adding work
36+
to the render path.
37+
38+
Compression does not move uniformly. Compared with the approved candidate,
39+
minified sizes are unchanged, while the built DOM entry adds 39 Brotli bytes.
40+
Against the original baseline, that entry is +44 minified, +36 gzip and
41+
+72 Brotli bytes. DOM client, combined client and default-Vite combined client
42+
remain smaller in all three formats. The JSON records include every feature
43+
variant, including Brotli increases in some variants. No additional budget
44+
increase is made for the review fix.
45+
46+
The earlier recovery repair and its failed size checks remain recorded in
47+
the Container report `reports/redact-hydration-repair-2026-10-04.md`.
48+
The new size budget does not waive hydration, context, event, state, cleanup,
49+
type checking, build verification or the strict three-engine real-site checks.

0 commit comments

Comments
 (0)