Repository navigation
fix(compiler): track an inherited method's receiver in use() memo dependencies - #1821
Conversation
…pendencies An inferred dependency for a one-level method call `source.read()` compared the own function `source.read` alone. When two objects share one own function, swapping the receiver kept that identity, so an inferred effect stayed subscribed to the old object and an inferred memo kept its old value (#1788). `__methodDep` now keeps an own function's identity only when it is an arrow, which cannot see `this`; any other own method tracks its receiver, as an inherited one already did and as React Compiler does for every method call. The arrow check reads the function's source text, skipping it for functions that own a `prototype`. Guarded plain reads pass a new `read` flag, so a guarded read of a function value still compares the value. Every emitter (component hooks, plain hooks, inline hook memos, Strong caches, signal captures, and binding-program refs) builds the flags from one helper. Closes #1788. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Classify every own function with the source pattern alone. The `prototype` pre-filter and the `(` fast path saved about 20 ns per call but cost 100 raw bytes in every bundle that ships the helper. A callable proxy's source reads as native code and fails the pattern before `name` is read, so the probe needs no exception guard. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Folding the leading-`(` check into the arrow pattern applied the `async`
name guard to every arrow, so `{ async: () => … }` tracked its receiver.
Only source that may be a method named `async` needs the guard; a
parenthesized arrow cannot be one.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1817 routes skipped `root.prop` reads in memoized use() arguments through the guarded `__methodDep` probe. That probe now treats a guarded call's own non-arrow function as receiver-dependent, so a skipped read of a stable ordinary function would reload whenever its container is rebuilt. The probe is a read, never a call, so it passes the `read` flag like the other guarded reads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The unguarded own-property path classified a method without the fallback the guarded path has. A patched `Function.prototype.toString` or a throwing `name` getter then failed the whole inferred dependency array. A probe that throws now counts as a method, as a failed guarded probe already does, and the authored call keeps any exception. The bare-parameter arrow cases now build their source with the Function constructor: the test transform re-prints `v => v` as `(v) => v`, so those cases had not reached the identifier branch of the arrow pattern. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reference solution calls `props.onTotal(total)` from an inferred effect. #1818 makes a call through an own non-arrow function track its receiver, as React Compiler does, and a `vi.fn()` is an ordinary function that records `this`. Passed directly, every rebuilt props object became a real dependency and the grader's "no unrelated repeat" step saw a second call. Each observer now reaches the component through a stable arrow, as a parent passes a callback; the assertions still read the spies, so a solution with a `null` or hand-written array still fails. The manifest's grader digest is regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…endencies A batched use() argument recorded a called one-level member by its value, so `use(load(count.toFixed(1)))` depended on `Number.prototype.toFixed` and never refreshed when `count` changed. collectDepPaths now records a called member through the guarded `__methodDep` descriptor probe: an inherited method, accessor, or primitive receiver tracks the receiver, while an own function of any kind keeps its identity. Tracking the receiver of an own non-arrow function, as inferred hook dependencies do, would key `use(props.load(id))` on a rebuilt props object and start a fresh request on every parent render and boundary retry. 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.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Method-call deps skip TS receivers
- Applied unwrapTsExpr to callee.object in the CallExpression handler and to member.property in staticDepMemberName so that TS-wrapped receivers (props!, props as T, etc.) and computed keys ('load' as const) are correctly peeled to their underlying Identifier/Literal, matching the unwrapValue already used by staticMemberInfo in hook-deps.js.
Or push these changes by commenting:
@cursor push 1d78a83229
Preview (1d78a83229)
diff --git a/packages/octane/src/compiler/compile.js b/packages/octane/src/compiler/compile.js
--- a/packages/octane/src/compiler/compile.js
+++ b/packages/octane/src/compiler/compile.js
@@ -18077,12 +18077,9 @@
const member = depPathMember(node);
if (member === null) return null;
if (!member.computed && member.property.type === 'Identifier') return member.property.name;
- if (
- member.computed &&
- member.property.type === 'Literal' &&
- typeof member.property.value === 'string'
- ) {
- return member.property.value;
+ if (member.computed) {
+ const prop = unwrapTsExpr(member.property);
+ if (prop?.type === 'Literal' && typeof prop.value === 'string') return prop.value;
}
return null;
}
@@ -18342,10 +18339,11 @@
case 'CallExpression': {
const callee = depPathMember(unwrapTsExpr(n.callee));
const name = staticDepMemberName(callee);
- if (callee?.object.type === 'Identifier' && name !== null) {
- if (isFree(callee.object, callee, 'object') && !deferredAmbient(callee.object.name)) {
+ const obj = callee ? unwrapTsExpr(callee.object) : undefined;
+ if (obj?.type === 'Identifier' && name !== null) {
+ if (isFree(obj, callee, 'object') && !deferredAmbient(obj.name)) {
const member = b.member(
- b.id(callee.object.name),
+ b.id(obj.name),
callee.computed ? b.literal(name, JSON.stringify(name)) : b.id(name),
callee.computed,
);You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 0f03a0d. Configure here.
Benchmark report🟢 No budget breaches, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 60 measured values. Public-import reachability bundles (bytes)No changes across 105 measured values. |
… wrappers `props!.load(id)`, `(props as T).load(id)`, and `props['load' as const](id)` call the same member as `props.load(id)`, but collectDepPaths only unwrapped the callee, so a wrapped receiver or key fell back to the whole `props` object. A `function` loader then restarted on every parent render and boundary retry. Unwrap the receiver and a computed key for reads and calls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 8cdd375 | Commit Preview URL Branch Preview URL |
Oct 06 2026, 07:43 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 8cdd375 | Commit Preview URL Branch Preview URL |
Oct 06 2026, 07:45 PM |


Summary
Builds on #1818, which has merged;
mainis merged in, so the diff is only this change.A batched
use()argument memo recorded a called one-level member by its value, so it missed receiver changes:Number.prototype.toFixednever changes, so aftercountwent from 1 to 2 the text stayedfirst:1.0. This is the bug class of #542, in a different code path. The cause iscollectDepPathsincompile.js, which builds.tsrx_$puPub/_$warmMemocreation dependencies, server prop-creation memos, and plain-hookuse()memos (slot-hooks.js, via #1817).collectDepPathsnow recordsroot.m(...)as__methodDep(root, 'm', true, true). That is the guarded own-descriptor probe the runtime already provides, so there is no runtime change:count.toFixed(1)now trackscount);undefined; nullish receiver: a stable marker, with no throw and no getter call.Why not #1818's receiver rule
Inferred hook dependencies (#1818) track the receiver of every own non-arrow function. Applying that rule to
use()memos turnsuse(props.load(id))with afunction load()loader into a request that restarts on every parent render and every boundary retry. A@tryretry rebuilds the child's props, the memo misses, a fresh promise suspends again, and the cycle never ends.benchmarks/recursive-context'sWarmPlanControlhas exactly this shape, and its verify asserts one child load. On #1818's head it loads the child once. With the receiver rule, the child loaded 51 times before the probe's guard stopped it. With this PR it loads once.The cost: an own non-arrow function shared by several objects (#1788's case), called as
source.read()inside ause()argument, is not witnessed when onlysourcechanges.docs/differences-from-react.mddocuments this and recommends passing the value it reads as an argument instead.Changes
compile.jscollectDepPaths: aCallExpressionwhose callee is a free one-level static member (including TS-wrapped, optional, and string-computed forms) pushes a guarded descriptor probe under its own…()key. A plain read of the same member elsewhere keeps its own value dependency. Arguments after an optional link are still skipped, and render-local roots are still coarsened.compile.jsdepPathRoot/staticDepMemberName(Bugbot follow-up, 506ba1d): reads and calls see through erased TS wrappers on the receiver and on a computed key, soprops!.load(id),(props as T).load(id)andprops['load' as const](id)get the same probe asprops.load(id)instead of falling back to the wholepropsobject. Repo corpus: 0 further compiles changed.slot-hooks.js: comment only.docs/differences-from-react.md: a parallel-use()bullet on method-call dependencies and how they differ from inferred hook deps.octanepatch.Validation
pnpm format:check(scopedformat:files:checkon the changed files passes)pnpm typecheck(scopedtypecheck:fileson the changed files passes)pnpm test(not run locally because of the machine-load rule; CI runs it)packages/octane/tests/creation-dependencies.test.ts, 990 passed onoctaneand 1,968 onoctane+octane-prodat the earlier iteration.New tests in
creation-dependencies.test.ts(use() method-call dependencies):first:1.0instead offirst:2.0). The skipped-argument case already passed there; it covers the neighboring path.functionkeeps the memo, with no reload, under tsrx and ts.functionloader prop under a retried@trystarts once.x!.m(),(x as any).m()andx['m' as const](); those 30 cases failed before 506ba1d.Compiled output corpus (base #1818 head vs this PR, client/server × dev/prod, with
OCTANE_COMPILE_ASSERT_LOC=1):following.includes(…),a.slice(…)andanswer$.get()previously keyed on a prototype method;props.load(…)now keys on the own value via the probe.compiled/sourcegzip, guard ≤ 1.3): 32,392 → 32,416 bytes, ratio 1.1963 → 1.1972.Per-render cost (Node microbenchmark, ns per dependency evaluation):
__methodDepRisk / follow-ups
use()memos by design. This is documented.Provenance
agent-authored)🤖 Generated with Claude Code
Note
Medium Risk
Compiler-only change that alters memo invalidation for every creation that calls a one-level method, with a small per-render descriptor-probe cost; behavior is heavily tested but touches parallel
use()and Suspense retry paths.Overview
Memoized
use()arguments (and the same dependency policy for plain.tshooks and server prop creations) now treat one-level method calls via a guarded__methodDepprobe instead of depending on the callee value alone.Inherited or accessor methods (e.g.
use(load(count.toFixed(1)))) invalidate when the receiver changes, fixing stale labels whencountupdates butNumber.prototype.toFixeddoes not. Own functions (arrow orfunction, includingprops.load(id)) still key only on the function identity so rebuiltpropsor@tryboundary retries do not restart requests in a suspend loop.depPathRoot/staticDepMemberNamepeel erased TypeScript wrappers on receivers and computed keys soprops!.load, casts, andas conststring keys match plainprops.loadfor both reads and calls. Docs describe how this differs from inferred hook deps (where own non-arrow methods track the receiver). New matrix tests cover receiver refresh, stable own methods, retried boundaries, and TS spellings.Reviewed by Cursor Bugbot for commit 8cdd375. Bugbot is set up for automated code reviews on this repo. Configure here.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.