Skip to content

fix(web): nested slot fills see the enclosing fill's context - #4131

Merged
ryansolid merged 3 commits into
nextfrom
claude/project-thread-58026x-nested-ctx
Oct 17, 2026
Merged

ryansolid merged 3 commits into
nextfrom
claude/project-thread-58026x-nested-ctx

Conversation

@ryansolid

@ryansolid ryansolid commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Before: a client fill nested in server content that another fill places (a region) did not see the context that enclosing fill provides. The server rendered the nested fill while the enclosing occurrence's args were still being evaluated, before the enclosing fill existed, and under the server component's zone owner. The client mounted it under the boundary owner. Both sides read the default. Also, when a fill wrapped its region in a provider (<Ctx value={x}>{props.children}</Ctx>), the server counted the region as occluded because the provider's children only resolve during the walk. It shipped the region as a data record and left the section empty. On the client, a fill whose root is a provider rendered a detached copy instead of claiming the server markup.

After: nested fills see the enclosing fill's context everywhere. That covers the server render, eager hydration, deferred hydration (including an inner occurrence that mounts before its enclosing one through mountEnclosing), occluded regions that are placed later, and occurrences a stream or live hole adds to a region.

A fill in a region is the enclosing fill's child, the same as in a plain client tree: it renders and mounts where the region is placed, under the owner that placed it.

How.

  • Server (frame-sink.ts): when a fill is called during an enclosing occurrence's arg evaluation, it parks. It mints its occurrence id at the call but leaves a token in the region's markup. The region thunk swaps each token for the fill's range, rendered under the placing owner in a fresh sc- hydration scope. For an occluded region, the swap happens when its record is serialized. The usage flip (lock and serialize regions that were not used) now runs as the range's tail, after the fill's output has resolved, so regions placed inside a provider ship as markup.
  • Client (regions-tier.ts, lazy): a read of a region element through the slot props places it under the reader's owner. A fill nested in that region mounts under the placing owner. If the region is unplaced (occluded, or its placement was disposed), the fill waits. The next placement mounts it fresh. The eager client only calls into the tier.
  • Client (client.ts): both claim windows of one fill share one claim owner, created under the binding owner. Content the first window evaluated lazily, such as a provider's children, now claims when the second window reads it.

How did you test this change?

New tests. Each one fails without the fix:

  • test/server/frame-nested-fill-context.spec.tsx (server config) renders a page with a badge inside a panel that provides Theme, a badge outside it, an open drawer and a closed drawer. It checks the markup reads dark / default / drawer, that the panel's region ships as markup, and that the closed drawer's region ships as a record. It writes the committed artifact.
  • test/hydration/frame-nested-fill-context.spec.tsx (hydrate config) checks that every badge adopts the server's nodes without warnings and that seen records the context each badge read. It then closes the drawer (disposes its badge), opens it again (fresh remount under the drawer's context), and opens the occluded drawer (its badge mounts on first placement).
  • test/hydration/frame-nested-fill-context-deferred.spec.tsx turns on deferred hydration. A click inside the inner occurrence mounts the panel, then the badge, and the badge reads dark and sees the click.
  • test/consistency/nested-fill-context.spec.tsx (stream face) covers a region with a live hole: the badge reads the panel's provider, and so does a badge that a hole patch adds later.

Suites (packages/web):

  • vite.config.mjs: 152 files, 1375 passed.
  • vite.config.hydrate.mjs: 114 passed and 1 skipped; 509 passed, 16 expected fail, 2 skipped.
  • vite.config.server.mjs: 190 passed and 1 failed; 1712 passed, 3 expected fail, 2 skipped. The one failure is the known Node 22 container failure "keeps a rebuild failure's own error", which is unrelated.
  • tsc on tsconfig.build.json and tsconfig.test.json is clean.

Size (scripts/size, local linux, brotli / minified vs next):

scenario brotli minified
frames: eager client consumer 12,216 → 12,235 (+19) +3
page: base server components (floor) 33,421 → 33,441 (+20) +12
page: live server components (floor) 37,510 → 37,565 (+55) +6
page: compiled base server components 35,290 → 35,408 (+118) +12
page: compiled live server components 41,463 → 41,439 (−24) +3
page: base + router 40,884 → 40,817 (−67) +3
page: live + router 47,001 → 47,006 (+5) +1
regions.js (lazy, not counted) 0.80 → 1.07 KB

The minified growth is +1 to +12 B, but brotli moves −67 to +118 B with layout noise. Four caps were set to measured + 10 B, rounded up to 0.01 KB, with dated ledger entries: frames 12.25 KB, compiled base 35.42 KB, and the two frozen floors in floor-caps.json, base page 33.46 KB and live page 37.58 KB.

Server hot paths: the parking and flip only run on document slot calls; paths without slots allocate nothing new.

Size-Exception: nested slot fills see the enclosing fill's context (+12 / +6 B minified on the two page floors; the brotli growth is layout noise). Accepted by @ryansolid, 2026-10-17.

CodSpeed: the one regression (mount 4000 rows: memo + sync render effect only) is a signals-only bench this PR doesn't touch; known noise on unrelated PRs.

🤖 Generated with Claude Code

https://claude.ai/code/session_012xU4iGQqRKP12d5Nkr4BA2

A fill nested in a region (server content an enclosing fill places) now
renders and mounts under the owner that placed the region, on the server
and the client, so it reads the context the enclosing fill provides.

Server: a fill called while an enclosing occurrence's args evaluate parks
as a token the region expands at placement; the usage flip runs at the
range's tail, after provider children resolved. Client: nested fills mount
under the region's reader owner, wait while unplaced, remount at the next
placement; both claim windows of a fill share one claim owner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012xU4iGQqRKP12d5Nkr4BA2
Placement bookkeeping (which owner placed a region, the nested fills
waiting on it) lives in the lazy regions tier: no region exists without
it, so the eager client keeps only the read hook and the call. Size
ledger for the four scenarios over their caps (+3..+12 B minified).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012xU4iGQqRKP12d5Nkr4BA2
@changeset-bot

changeset-bot Bot commented Oct 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d76dc62

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@solidjs/web Patch
@solidjs/babel-plugin Patch
@solidjs/diagnostics Patch
@solidjs/element Patch
@solidjs/h Patch
@solidjs/html Patch
test-integration Patch
board-example Patch
server-dbmon-example Patch
todos-server-example Patch
@solidjs/compiler Patch
@solidjs/signals Patch
solid-js Patch
@solidjs/universal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown

Size (brotli, eager entry chunk)

scenario head vs base minified vs base minified vs recorded cap lazy chunks (not counted)
signals: core floor (createSignal/Memo/Effect/Root/flush) 7.24 KB 0 B 0 B 0 B 7.25 KB ✅
signals: + createStore 14.77 KB 0 B 0 B 0 B 14.79 KB ✅
signals: + isPending/latest 9.95 KB 0 B 0 B +4 B 9.96 KB ✅
signals: + until/refresh (truth readers, no optimism) 7.85 KB 0 B 0 B 0 B 7.86 KB ✅
app: render + one signal (the simple-app floor) 9.55 KB 0 B 0 B 0 B 9.56 KB ✅
app: hydrating (no stores) with Show/For/Loading/Errored/lazy 18.17 KB 0 B 0 B 0 B 18.19 KB ✅ lazy-page.js 0.04 KB
app: hydrating + every store primitive family 30.09 KB 0 B 0 B +4 B 30.09 KB ✅ lazy-page.js 0.04 KB
app: CSR with Show/For/Loading/Errored/lazy 13.12 KB 0 B 0 B 0 B 13.14 KB ✅ lazy-page.js 0.04 KB
app: CSR, observe tier (same app on the observe artifacts) 14.87 KB 0 B 0 B 0 B 14.91 KB ✅ lazy-page.js 0.04 KB
app: CSR, observe tier + attribution engine enabled 29.44 KB 0 B 0 B 0 B 29.48 KB ✅ lazy-page.js 0.04 KB
app: compiled floor (one template, one text hole, one delegated click) 9.75 KB 0 B 0 B +2 B 9.77 KB ✅
app: compiled CSR (JSX todo app: spread/merge/omit, events, class/style, keyed For, Show, Loading + lazy, store) 25.94 KB 0 B 0 B 0 B 25.95 KB ✅ stats.js 0.18 KB
app: compiled hydrating (the same JSX todo app through hydrate(), compiled hydratable) 31.95 KB 0 B 0 B 0 B 31.96 KB ✅ stats.js 0.20 KB
frames: eager client consumer (frames client + transport, lazy codec) 12.23 KB +19 B (+0.2%) +3 B 0 B 12.25 KB ✅
page: base server components (hydrating + dynamic + frames + sf reference) 33.44 KB +20 B (+0.1%) +12 B 0 B 33.46 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.07 KB, trace.js 8.97 KB, wire.js 1.33 KB
page: live server components (base + live/GET + action + isPending/latest) 37.56 KB +55 B (+0.1%) +6 B 0 B 37.58 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.07 KB, trace.js 8.99 KB, wire.js 1.33 KB
page: compiled base server components (the base page as JSX: templates with class/style/attributes/events, For/Show; no spread) 35.41 KB +118 B (+0.3%) +12 B 0 B 35.42 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, regions.js 1.06 KB, sc-comments.js 0.20 KB, trace.js 9.02 KB, wire.js 1.33 KB
page: compiled live server components (the compiled base page + live/GET + action + isPending/latest) 41.44 KB −24 B (−0.1%) +3 B +3 B 41.48 KB ✅ eager (counted): web.js 21.61 KB; assets.js 0.78 KB, decode.js 6.25 KB, regions.js 1.07 KB, sc-comments.js 0.19 KB, trace.js 9.02 KB, wire.js 1.33 KB
page: base + router (base page + @solidjs/router: createRouter, two routes, preload, useNavigate) 40.82 KB −67 B (−0.2%) +3 B +3 B 40.90 KB ✅ assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.07 KB, server.js 1.02 KB, serverForms.js 3.60 KB, trace.js 9.03 KB, wire.js 1.33 KB
page: live + router (live page + @solidjs/router: createRouter, two routes, preload, useNavigate) 47.01 KB +5 B (+0.0%) +1 B +1 B 47.02 KB ✅ eager (counted): client.js 26.70 KB; assets.js 0.78 KB, decode.js 6.25 KB, lazy-page.js 0.04 KB, regions.js 1.07 KB, server.js 1.02 KB, serverForms.js 3.30 KB, trace.js 9.03 KB, wire.js 1.34 KB
server: floor (getRequestEvent + isServer) 1.33 KB 0 B 0 B 0 B 1.34 KB ✅
server: renderToString (the server-render floor) 20.57 KB 0 B 0 B 0 B 20.59 KB ✅

Bundled with Rolldown (what Vite ships), brotli q11, decimal KB. A scenario fails only when it is over its brotli cap and its minified size is more than 20 B over the minified recorded with the cap; over the cap within that allowance is brotli layout noise and passes with a warning. Caps and their recorded minified in scripts/size/scenarios.js; the floor and page caps in floor-caps.json are frozen (lower only, or Size-Exception: in the PR body). npm run ratchet lowers caps per RC; it never raises one (scripts/size/README.md).

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 39020014523

Coverage remained the same at 77.564%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1339
Covered Lines: 1097
Line Coverage: 81.93%
Relevant Branches: 1050
Covered Branches: 756
Branch Coverage: 72.0%
Branches in Coverage %: Yes
Coverage Strength: 27.83 hits per line

💛 - Coveralls

@codspeed

codspeed Bot commented Oct 17, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.87%

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚠️ 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

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 194 untouched benchmarks
⏩ 5 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ memo + sync render effect only (reference) 27.6 ms 32.4 ms -14.89%
⚡ createStore setter: delete + set one root key (#3044 overlay) 1.9 ms 1.8 ms +8.57%

Tip

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


Comparing claude/project-thread-58026x-nested-ctx (d76dc62) with next (7010268)2

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on next (db4b281) during the generation of this report, so 7010268 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Copy link
Copy Markdown
Member Author

CodSpeed's one regression, mount 4000 rows: memo + sync render effect only (reference) (−14.9%), is not this PR's. It is a pure @solidjs/signals bench, and this PR changes nothing in signals. Its diff is limited to @solidjs/web server/frames code and tests. This same benchmark has swung −12% to −19% on other unrelated PRs, and CodSpeed itself flags "different runtime environments" for this comparison. No fix is needed. I'm leaving it for acknowledgement on CodSpeed rather than re-running.


Generated by Claude Code

@ryansolid
ryansolid merged commit fb49849 into next Oct 17, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants