Repository navigation
fix(octane): resolve a component's signal handles from its nested @{ … } blocks - #1761
Conversation
… … }` blocks A nested block got a signal instance of its own, so a component handle it read resolved to a second cell: a second query request, and a value computed from signals the component never updated. The block now links to the template that renders it, as directive arms and keyed rows do, on the client and the server. It still owns the declarations it evaluates. Fragment renderers link to their component the same way, so a nested block in returned JSX reads the component's cells below the root too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Renderer skips nested block owner
- In stampSignalInstanceKey, a renderer inside a TEMPLATE_INVOCATION_SITE scope now keeps the parent scope itself as signalInstanceParent instead of inheriting the parent's parent, so scopeSignalOwner walks through the nested block instead of skipping it.
Or push these changes by commenting:
@cursor push 5687c6c987
Preview (5687c6c987)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -965,9 +965,15 @@
}
// A renderer adds no key segment: it carries its parent's identity, and
// stays unstamped below an unstamped parent so keys walk on through it.
+ // When the parent is a template block (nested `@{ … }`), keep the block
+ // itself as the parent so scopeSignalOwner still walks through it.
const parent = key.parentScope;
const renderer = key.invocationSite === RENDERER_INVOCATION_SITE;
- scope.signalInstanceParent = renderer ? parent.signalInstanceParent : parent;
+ scope.signalInstanceParent = renderer
+ ? parent.signalInstanceSite === TEMPLATE_INVOCATION_SITE
+ ? parent
+ : parent.signalInstanceParent
+ : parent;
scope.signalInstanceSite = renderer ? parent.signalInstanceSite : key.invocationSite;
scope.signalInstanceValue = renderer ? parent.signalInstanceValue : key.key;
scope.signalInstanceHasKey = renderer ? parent.signalInstanceHasKey : key.hasKey;
diff --git a/packages/octane/tests/hydration/signal-declaration-owner.test.ts b/packages/octane/tests/hydration/signal-declaration-owner.test.ts
--- a/packages/octane/tests/hydration/signal-declaration-owner.test.ts
+++ b/packages/octane/tests/hydration/signal-declaration-owner.test.ts
@@ -473,6 +473,42 @@
);
});
+ // A host descriptor inside a nested block creates a renderer. An inner
+ // nested block rendered through that host must still resolve the outer
+ // block's signals, not skip past the block to the component.
+ it.each(MODES)(
+ "reads the outer block's signal from an inner block through a host ($name)",
+ async ({ dev, strong }) => {
+ const view = await mountClient(
+ `import { query$, signal$ } from 'octane/signals';
+export function App(props) @{
+ const source$ = query$(() => 'source', props.load);
+ <section>
+ <output>{source$.snapshot().status as string}</output>
+ @{
+ const outer$ = signal$(0);
+ <div>
+ @{
+ const inner = source$.snapshot();
+ <p><output>{\`\${inner.status === 'ready' ? inner.value : inner.status}:\${outer$.get()}\`}</output></p>
+ }
+ </div>
+ }
+ </section>
+}`,
+ { dev, strong },
+ );
+ try {
+ expect(view.requests).toHaveLength(1);
+ await view.settleAll('ready');
+ expect(view.texts()).toEqual(['ready', 'ready:0']);
+ expect(view.requests).toHaveLength(1);
+ } finally {
+ view.unmount();
+ }
+ },
+ );
+
// Returned JSX renders through a fragment renderer, which carries the
// instance of the component it renders for. A nested block inside it still
// reads that component's cells, at the root or below another component.You can send follow-ups to the cloud agent here.
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
8 other measured values are unchanged. Public-import reachability bundles (bytes)
32 other measured values are unchanged. |
A host or fragment renderer copies the recipe of the scope it renders for, including a nested block's `t:` site, so it was treated as a block and linked past it to the block's parent. A block nested in that renderer then missed the outer block's declarations and started its own query. Check the key first: a renderer keeps its parent's key and links to it, and only a scope that adds a segment of its own links to the scope that rendered it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nto fix/nested-block-signal-owner
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Lite renderer drops enclosing owner
- Added a liteScope back-reference on LiteBlockImpl so that scopeSignalOwner can resolve through the stand-in to the owning scope when a renderer's parentBlock is a LiteBlockImpl, instead of dropping the enclosingOwner link.
Or push these changes by commenting:
@cursor push b0867e403b
Preview (b0867e403b)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -1131,6 +1131,8 @@
scope.signalInstanceSite === TEMPLATE_INVOCATION_SITE ? scope.signalInstanceParent : null;
if (parent !== null && !(parent instanceof LiteBlockImpl))
identity.enclosingOwner = scopeSignalOwner(parent) as SignalRendererOwnerIdentity;
+ else if (parent instanceof LiteBlockImpl)
+ identity.enclosingOwner = scopeSignalOwner(parent.liteScope) as SignalRendererOwnerIdentity;
// A retry owner must not keep an abandoned renderer tree alive. This
// existing opaque identity object is also its own facade-state token.
identity.instanceOwner = identity;
@@ -11849,8 +11851,13 @@
declare signalInstanceValue: unknown;
declare signalInstanceHasKey: boolean;
declare signalInstanceResolved: string | undefined;
+ // Back-reference to the lite scope whose block this stand-in is. A renderer
+ // child's parentBlock is this stand-in, and scopeSignalOwner needs the scope
+ // to resolve the enclosing owner (the lite scope is not reachable from the
+ // parentBlock chain alone).
+ declare liteScope: Scope;
- constructor(parentNode: Node, endMarker: Node | null, parentBlock: Block) {
+ constructor(parentNode: Node, endMarker: Node | null, parentBlock: Block, liteScope: Scope) {
this.parentNode = parentNode;
this.endMarker = endMarker;
this.parentBlock = parentBlock;
@@ -11862,6 +11869,7 @@
this.signalInstanceValue = undefined;
this.signalInstanceHasKey = false;
this.signalInstanceResolved = undefined;
+ this.liteScope = liteScope;
}
}
@@ -11980,7 +11988,7 @@
endMarker = hydration.parkAtHole((inPlace = anchor));
}
}
- scope.block = new LiteBlockImpl(host, endMarker, parentScope.block) as unknown as Block;
+ scope.block = new LiteBlockImpl(host, endMarker, parentScope.block, scope) as unknown as Block;
stampSignalInstance(scope, parentScope, invocationSite);
if (adoptedOpen !== null && adoptedClose !== null) {
hydration!.liteRanges.set(scope, {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit f5f44d5. Configure here.
…nent A hookless component's blocks hang off a DOM stand-in rather than its scope, and the stand-in has no owner of its own. A renderer the component renders, such as value-position JSX, therefore skipped the link, and a nested block in it read a handle prop from a cell of its own. The stand-in records the scope the component is registered on, so resolve the component's scope from that scope's children. Arms inside a hookless component now link the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1761 now resolves a hookless component's scope from its DOM stand-in, so a renderer the component renders links to it: 75 more raw bytes in client owner creation. Only raised values; no budget is lowered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rement The CI runner measures #1761's bindings app at 204,213 total brotli bytes, 6 over the committed budget. The local measurement fits, because brotli output differs slightly between environments; raw and gzip match exactly. Set it to CI's measurement + 256. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
#1761 (#1793) #1782 measured the #1764 fix on its own, and #1760 measured #1761 on its own. With #1761 now on main, adding the fix overruns 47 budgets by up to about 135 raw bytes. Each value is measured on main 9c84293 with the fix applied, plus the standard headroom. Co-authored-by: Claude Opus 5.5 <[email protected]>
Budgets move by the measured esbuild-to-Oxc difference on the same source (budget - max(0, esbuild - oxc)), so the methodology change lowers 131 values, keeps 28, raises none, and leaves the headroom #1782 granted to #1783 in place. The baseline, ratio guards and website summary are recomputed from the merged source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* ci(bench): measure bundle sizes with Vite 8's default minifier The bundle-size and bundle-reachability harnesses forced Vite's `minify: 'esbuild'`. That mode turns Rolldown's own minifier off, and with it the dead-code elimination that removes branches guarded by a never-written module flag, so the numbers were not what a Vite app ships. - run.mjs builds every framework with `minify: 'oxc'` (Vite 8's default client minifier), still identical settings for every target. - run-minimal.mjs builds its Vite scenarios with `'oxc'`; the esbuild bundler scenarios keep esbuild's `minify: true`. The async-identity encoder check accepts Oxc's template-literal quotes. - Every budget is ratcheted down (144 lowered, 15 unchanged, 0 raised), the bundle-size baseline is re-recorded, the 18 cross-framework ratio guards are re-cut, and the website summary and copy follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-measure the Oxc budgets on main with #1761 and #1782 Budgets move by the measured esbuild-to-Oxc difference on the same source (budget - max(0, esbuild - oxc)), so the methodology change lowers 131 values, keeps 28, raises none, and leaves the headroom #1782 granted to #1783 in place. The baseline, ratio guards and website summary are recomputed from the merged source. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(website): compare home summary ceilings at stable precision The smoke test rounds each summary row to 15 significant digits because Math.log/exp can differ by one ULP between libc implementations, but it compared the bundle-size range ends exactly. Those ends are geometric means too: the recorded Solid ceiling was 0.9500824085923075 on macOS and 0.9500824085923076 on the Linux runner. Round them the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-derive the Oxc budgets on main with #1766, #1768, #1770, #1772 and #1794 Same method as before: each budget is main's value minus the measured esbuild-to-Oxc difference on the merged source, never raised (131 lowered, 28 unchanged). The baseline record and home summary follow the new bytes; every ratio guard still holds with the ceilings already cut. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-derive the Oxc budgets on main with #1783 #1783 landed and spent the headroom #1782/#1793/#1794 granted it. Each budget is again main's value minus the measured esbuild-to-Oxc difference on the merged source (131 lowered, 28 unchanged, none raised). The baseline record, home summary and refresh note follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): re-cut the cross-framework ratio guards after #1784 With #1784's hydrating flag folded by Oxc, Octane's totals shrink 8.5-10% instead of about 5%, so the total-gzip ceilings had grown about 6% loose. They are re-cut at about 1.5% headroom on the merged-source measurement; application-code ceilings are unchanged. All 72 bundle-size guards hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>


Summary
A nested
@{ … }block in a component's template now resolves the component'ssignal$,derived$andquery$handles to the component's own cells, as directive arms and keyed@forrows already do. On main, each block got cells of its own. It started a second request for every query it read, in the browser and on the server, and it computed derived values from signals the component never updated. Follow-up to #1755, whose risk section flagged this.On main,
loadruns twice. After a click the block shows1valuewhile the component's count is 2. Hydration also refetches the block's read instead of resuming the server's result.Size budgets: covered by #1773 (merged 2026-10-05), which raised budgets for this PR and the stacked children fix #1774. This PR grows every client bundle by about 162 raw bytes; #1760, the original budget PR, is now redundant.
Why
The contract is the paragraph in
docs/signals.mdthat begins "Module declarations resolve to request-local cells…". It covers three cases:A nested block is not an authored component invocation. It closes over the body's declarations and renders at its sibling position, so it is part of the component's template. Arms and rows were linked to their component by #1530. Nested blocks were missed because the runtime renders them through the bare-function
childSlotpath, which stamped a structural instance (thelegacysegment). An instance with its own key never received anenclosingOwner. #1706's__declaredlowering only sees authored functions, and a child-position block is aJSXCodeBlockuntil compile time.Changes
runtime.ts):childSlotstamps a render function rendered as a child with a new't:'invocation site (TEMPLATE_INVOCATION_SITE). It does so only inside the existing signals-enabled branch. Compiled{children}keep the plain site: they belong to the template that authored them, not the component rendering them (see Risk).scopeSignalOwnergives such an owner anenclosingOwner: the owner of the scope that rendered it. For a lightweight component, that is its scope rather than its DOM stand-in. The block keeps its own instance key, so it still owns, retires and resumes the declarations it evaluates.t:site, so the renderer links to that block rather than past it. A renderer is a_frag$N, or the host-descriptor renderer, recognized as a scope whose instance key equals its structural parent's.scopeSignalOwnerfinds the component's scope in thechildrenof the parent the stand-in records. This replaces the guard that dropped the link, so arms inside a hookless component link the same way.runtime.server.ts):ssrChildValue,ssrDescriptorPart) use the same site, so instance keys stay identical to the client.ssrComponentpasses the owner it renders inside to the frame's new owner.serverSignalQueryAttemptObserveralready walksenclosingOwner, so a block's read of the component's query observes, and later resumes, under the component's key.docs/signals.mdadds nested@{ … }blocks, including one in returned JSX, to the template rule and to "owns only the declarations it evaluates".octanepatch.Validation
pnpm format:check: not run repo-wide.format:files:checkpassed on every changed file.pnpm typecheck: not run repo-wide.typecheck:filespassed onruntime.ts,runtime.server.tsand the test.pnpm test: not run locally; CI runs it.packages/octane/tests/hydration/signal-declaration-owner.test.ts, 121/121 inoctaneafter merging main (e233e4a, including perf(octane): stop shipping the signal binding runtime in apps without signals #1762's opaque-hole gating).hydration/signal-instance-identity.test.ts, which perf(octane): stop shipping the signal binding runtime in apps without signals #1762 changed, also passes (290 tests across both files). Before the size trim, it also passed inoctane-prod(prod and strong).framesshapesblockandrow blockcover each existing case: one browser query for setup plus template reads; the server query resumed with a setup read, and with template reads only.octane(dev). The same cases also fail inoctane-prod.legacysegment;server-render. Budgets were raised by ci(bench): raise byte budgets for the children signal owner fix #1773; with main merged (e166793), both--budgetscommands pass.Risk / follow-ups
<Card>{record$.get()}</Card>, the children read the parent'srecord$in a cell of their own: a second query on both sides. The children's owner should link to the component that authored them, not the one rendering them, so this needs a separate fix: either a creator owner recorded bymarkChildrenBlock, or__declaredlowering for children JSX.() => @{ … }that another component renders as{props.render}now links to that rendering component, for any reads that are not lexical method calls. Its lexical method calls still use fix(octane): resolve a body's signal declarations from the functions it creates #1706's__declared. Separately, a query read only through__declaredis not observed by the server's streamed selection, so hydration reports error 267.enclosingOwner. This only changes how reads that resolve in a renderer's owner pick their cell.legacytot:on both sides. Keys are per build, so no persisted seed is affected.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes signal instance keys and owner resolution across client SSR and hydration; behavior shift is broad but scoped to template nesting and covered by expanded tests.
Overview
Nested
@{ … }blocks in a component template now read the parent component'ssignal$,derived$, andquery$handles from the component's cells, matching directive arms and keyed@forrows. Previously each block got its own cells, which caused duplicatequery$loads and stale derived values on the client, server, and during hydration.The client and server runtimes introduce a
t:template invocation site for child render functions (excluding compiled{children}blocks), wireenclosingOwnerso reads resolve through the rendering template, and extend fragment renderer / hookless-component owner linking so nested blocks in returned or value-position JSX share one query.docs/signals.mddocuments the rule; hydration tests cover blocks, child props, and SSR resume.Reviewed by Cursor Bugbot for commit e166793. Bugbot is set up for automated code reviews on this repo. Configure here.