Skip to content

fix(octane): track the receiver of a shared own method in inferred dependencies - #1818

Merged
trueadm merged 8 commits into
mainfrom
fix/method-dep-receiver
Oct 6, 2026
Merged

trueadm merged 8 commits into
mainfrom
fix/method-dep-receiver

Conversation

@trueadm

@trueadm trueadm commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #1788.

An inferred dependency for a one-level method call such as source.subscribe() compared only the own function source.subscribe. When two objects share one own function, replacing the receiver kept that identity. The inferred effect stayed subscribed to the first object, and the inferred memo kept showing first. The explicit [source] controls behaved correctly.

__methodDep now chooses the dependency value from the method itself:

Method on the receiver Dependency Change
Own arrow function The function Unchanged
Any other own function: ordinary function, method shorthand, async, bound, native, proxy The receiver Was the function
Inherited method The receiver Unchanged
Absent (props.onReady?.()) undefined Unchanged

An arrow binds this lexically, so no receiver reaches its body. That keeps the existing optimization the issue asks to preserve: props.onChange(...) with a stable arrow callback (inline arrows, useCallback(() => …), state setters) stays quiet when the props container is rebuilt. Any other function can read this. React Compiler 1.0 also tracks the receiver for these calls: it compiles () => props.onChange(1) to $[0] !== props, and source.read() to $[0] !== source.

How the arrow check works

  • Source text is the only reliable tell. The check reads Function.prototype.toString and matches it against an anchored pattern: a leading (, x =>, async ( or async x =>. Ordinary functions start with function, classes with class, and methods with their property key. Bound, native and proxied functions read as function … [native code].
  • Methods named async. Their source also starts with async(, so source that doesn't start with ( must also have a name other than async. A parenthesized arrow such as { async: () => … } skips that check, per Bugbot.
  • Anything unrecognised tracks the receiver. That includes every function on engines that hide source text. The worst case is a spurious recompute, never a missed one.

Guarded plain reads get a read flag

The helper also serves guarded plain reads, such as if (x) use(props.handler). A read passes no receiver, so it keeps comparing the function value. The compiler now marks those reads with a fourth read argument.

All seven emitters take their flags from one methodDepFlags helper:

The binding-program ref emitter previously dropped the guarded flag entirely. It now passes the same flags as the other emitters.

Behavior change for vi.fn() callback props

A vi.fn() / jest.fn() mock is an ordinary function that records this. When a test passes one as a prop and a component calls it as props.log(...) from an inferred hook, the hook now re-runs whenever the props container is rebuilt. That is sound: the mock does observe the new receiver. It is also what React Compiler or [props] deps would do.

14 existing tests asserted the old behavior with vi.fn() props: 9 in auto-hook-deps-behavior, 3 in hooks, and 1 inline-ref step in behavior-root, in each of the dev and prod projects. They now wrap their spy in one stable arrow, which keeps each test's intent and its call-count assertions. The changeset calls this out.

The octane.inferred-hook-deps eval grader hit the same case. Its reference solution calls props.onTotal(total) from an inferred effect, and the grader passed vi.fn() observers. After discussion, the call keeps the React-parity rule. The grader now passes each spy through a stable arrow, as a parent component passes a callback, and its graderDigest is regenerated. Its assertions still read the spies, so a solution with a null or hand-written array still fails the "unrelated repeat" step.

Validation

  • pnpm format:check — not run repo-wide; pnpm format:files:check on every changed file passes
  • pnpm typecheck — not run repo-wide; pnpm typecheck:files on the six changed source files passes. Tests are outside the package's typecheck program, and the new fixtures use untyped props like their neighbours.
  • pnpm test — not run in full. Before the test edits, --project octane --project octane-prod ran in full with the fix: the only failures were the 14 vi.fn() cases above.
  • targeted tests, on the final head (--project octane): auto-hook-deps-behavior, signal-local-selectors. Earlier in the change, also hooks, behavior-root and guarded-hook-dependencies, in both octane and octane-prod.
  • pnpm sync — no generated changes

New regression coverage (each new case was seen failing first):

  • The issue repro, in dev and prod. Inferred effect, guarded effect, Strong effect and inferred memo. Each runs over a shared function method and over a method shorthand copied by spread. Before the fix, the effect stayed on first and the memo showed first. A Strong const declaration is pinned as a neighbour: it already keyed on the receiver.
  • Plain JavaScript hooks, with and without inline memo lowering.
  • Signal captures: the existing method captures in signals and effects scenario now runs a "shared own methods" receiver in all four dev/prod × Strong modes, for both derived$ and plain-hook declarations. That shape fails on main's helper.
  • Callback shapes. Arrow, async arrow, bare-parameter arrow, minified arrow and async bare-parameter arrow must stay inert across fresh props. function, async function, method shorthand, async method and a method named async must re-run with the new props as this.
  • Guarded reads of a stable non-arrow function stay inert, through the component, plain-hook and inline-memo emitters and the binding-program inline ref.

Mutation checks (each turned exactly its test red):

  • dropping the async name guard
  • ignoring read in the runtime
  • dropping read in slot-hooks
  • dropping read in plain-hook-memo
  • dropping the binding-program flags
  • making every own function track its receiver

Performance

__methodDep micro-benchmark, 4M calls on Node 24. Only own functions pay for the source probe:

Case main this PR
Own arrow, method or ordinary function ~9 ns ~40–50 ns
Inherited method ~5.5 ns ~5.5 ns
Absent optional handler ~9 ns ~10 ns

That is one toString slice plus an anchored regex, per one-level method-call dependency per render. A WeakMap cache measured about 8 ns for stable arrows but about 155 ns for a fresh arrow each render, and it adds ephemeron churn, so it was left out. An earlier version also had a prototype pre-filter and a ( fast path, each worth about 20 ns. They cost about 100 raw bytes, so they were dropped.

Emitted code grows only for guarded plain reads (, true, true).

Bundle size: needs #1819 first

The weather app ships the helper: framework +215 raw / +119 gzip, which exceeds its 32-byte headroom. #1819 is the budget-only raise required by CONTRIBUTING, and it lists the exact bytes. #1819 also ratchets main's deferred-hydration budget down: #1771's ratchet currently fails test shard 1/4 on main itself, so shard 1 fails here too. Merge #1819 first, then merge main into this branch.

Risk / follow-ups

  • Hooks may re-run more often for non-arrow callbacks. This is limited to non-arrow functions passed through a rebuilt container and called as container.fn(...) from an inferred hook or inline ref. That includes test mocks. Such hooks now re-run when the container changes, which matches React Compiler. Arrow callbacks, the common case, are unchanged.
  • Follow-up, not in this PR: batched use() memos record a called member by its value in collectDepPaths, e.g. [load, count.toFixed]. So use(load(count.toFixed(1))) stays at 1.0 after count changes. This predates this PR and is the same bug class in a separate compiler path; it's tracked as a separate task.
  • In-place replacement of a non-arrow method on the same receiver is not witnessed. This is a mutation, consistent with the inherited case and with React Compiler's receiver dependency. An arrow replaced in place is still witnessed.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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
Changes core compiler/runtime inferred dependency semantics; non-arrow callbacks and mocks called as props.fn(...) may re-run hooks more often when props objects are recreated, though arrow callbacks remain unchanged.

Overview
Inferred hook dependencies for one-level method calls (source.subscribe(), source.read()) no longer key only on the function identity when several objects share the same own method. The runtime __methodDep helper now treats own arrow functions as tracking themselves (unchanged for stable props.onChange arrows) and any other own function as tracking the receiver, matching React Compiler and fixing cases where effects and memos stayed pinned to the first object.

The compiler threads dependency metadata through a shared methodDepFlags helper, including a new read flag for guarded plain reads (e.g. if (props.enabled) props.log(props.handler)) so those still compare the function value, not the props bag. Emitters updated include hook-deps, slot-hooks, plain-hook-memo, signal captures, DOM binding inline refs, and use() probe paths.

Docs and a patch changeset describe the semantics; eval grader digest for octane.inferred-hook-deps is refreshed. Tests add receiver-sharing coverage and wrap vi.fn() callback props in stable arrows where the old “track function only” behavior would have made mocks look like spurious deps on container rebuilds.

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

…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]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 6, 2026
@trueadm
trueadm marked this pull request as ready for review October 6, 2026 13:11
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 15 value(s) increased within budget

Compares 014d87bcb, the merge commit's first parent with 6efccad9c on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.242 3.092 −0.0% −4.9% … +3.2% ⚪ within noise
octane-tsrx replace 7.892 8.167 +5.6% +0.7% … +9.2% ⚪ within noise
octane-tsrx add 2.808 2.758 −0.0% −5.0% … +1.7% ⚪ within noise
octane-tsrx update 0.166 0.149 −0.4% −6.8% … +6.3% ⚪ within noise
octane-tsrx select 0.006 0.006 +0.3% −3.3% … +2.7% ⚪ within noise
octane-tsrx swap 0.042 0.040 −1.1% −3.8% … +3.4% ⚪ within noise
octane-tsrx remove 0.021 0.021 +1.2% −1.2% … +4.4% ⚪ within noise
octane-tsrx runlots 32.917 30.675 −1.3% −5.7% … +1.8% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 −0.9% −3.9% … +1.7% ⚪ within noise
octane-tsrx clear 68.983 69.767 −0.7% −9.1% … +7.3% ⚪ within noise
octane-jsx run 4.567 4.567 ±0.0% −7.5% … +9.7% ⚪ within noise
octane-jsx replace 13.142 13.817 +7.3% −5.7% … +12.6% ⚪ within noise
octane-jsx add 3.983 4.225 −2.4% −4.7% … +2.4% ⚪ within noise
octane-jsx update 0.330 0.311 +0.7% −2.8% … +4.6% ⚪ within noise
octane-jsx select 0.166 0.169 −0.3% −2.7% … +1.4% ⚪ within noise
octane-jsx swap 0.277 0.287 −1.2% −8.9% … +3.6% ⚪ within noise
octane-jsx remove 0.251 0.257 +4.0% −3.5% … +15.5% ⚪ within noise
octane-jsx runlots 38.650 35.250 −3.9% −7.1% … +2.6% ⚪ within noise
octane-jsx select_lots 2.209 2.431 +7.9% −1.7% … +25.3% ⚪ within noise
octane-jsx clear 70.100 61.733 +3.3% −5.9% … +7.2% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx weather_js_raw 154,665 154,903 +238 (+0.2%) 🔴
octane-tsrx weather_js_gzip 50,099 50,224 +125 (+0.2%) 🔴
octane-tsrx weather_js_brotli 43,717 43,829 +112 (+0.3%) 🔴
octane-tsrx weather_app_raw 22,151 22,154 +3 (+0.0%) 🔴
octane-tsrx weather_app_gzip 7,869 7,872 +3 (+0.0%) 🔴
octane-tsrx weather_app_brotli 6,653 6,665 +12 (+0.2%) 🔴
octane-tsrx weather_fw_raw 132,514 132,749 +235 (+0.2%) 🔴
octane-tsrx weather_fw_gzip 42,230 42,352 +122 (+0.3%) 🔴
octane-tsrx weather_fw_brotli 37,064 37,164 +100 (+0.3%) 🔴
octane-tsrx full_fw_raw 562,173 562,408 +235 (+0.0%) 🔴
octane-tsrx full_fw_gzip 168,931 169,027 +96 (+0.1%) 🔴
octane-tsrx full_fw_brotli 142,211 142,249 +38 (+0.0%) 🔴
octane-jsx full_fw_raw 562,173 562,408 +235 (+0.0%) 🔴
octane-jsx full_fw_gzip 168,931 169,027 +96 (+0.1%) 🔴
octane-jsx full_fw_brotli 142,211 142,249 +38 (+0.0%) 🔴

45 other measured values are unchanged.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

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]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: Arrow named async tracks receiver
    • Changed ARROW_HEAD regex from \s* to \s+ after the async prefix so that async( (method) is rejected at the regex level, and removed the now-unnecessary method.name !== 'async' guard that was incorrectly rejecting parenthesized arrows with an inferred name of async.

Create PR

Or push these changes by commenting:

@cursor push 2061afd1bf
Preview (2061afd1bf)
diff --git a/packages/octane/src/method-dep.ts b/packages/octane/src/method-dep.ts
--- a/packages/octane/src/method-dep.ts
+++ b/packages/octane/src/method-dep.ts
@@ -80,17 +80,17 @@
 }
 
 // An arrow's source text starts with its parameters, after an optional
-// `async`: a parenthesized list, or one identifier followed by `=>`. Every
-// other function starts with `function`, `class`, or a method's property key,
-// and a bound, native, or proxied function reads as `function … [native code]`.
-// Anything this does not recognize counts as a method, which only costs a
-// spurious recompute. A method named `async` also reads as `async(`, so the
-// name check runs only after the pattern matched.
-const ARROW_HEAD = /^(?:async\s*)?(?:\(|[\w$]+\s*=>)/;
+// `async ` (with whitespace): a parenthesized list, or one identifier followed
+// by `=>`. Every other function starts with `function`, `class`, or a method's
+// property key, and a bound, native, or proxied function reads as
+// `function … [native code]`. A method named `async` stringifies as `async(`
+// with no whitespace, so requiring `\s+` after `async` excludes it without a
+// name check. Anything this does not recognize counts as a method, which only
+// costs a spurious recompute.
+const ARROW_HEAD = /^(?:async\s+)?(?:\(|[\w$]+\s*=>)/;
 
 function ownMethodDep(receiver: object, method: unknown): unknown {
-	return typeof method === 'function' &&
-		!(ARROW_HEAD.test(Function.prototype.toString.call(method)) && method.name !== 'async')
+	return typeof method === 'function' && !ARROW_HEAD.test(Function.prototype.toString.call(method))
 		? receiver
 		: method;
 }

You can send follow-ups to the cloud agent here.

Comment thread packages/octane/src/method-dep.ts Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
826be2d 2026-10-06T13:40:02.494Z View logs ↗
  • Build: In progress 🔵

View logs ↗
56685f9 2026-10-06T13:32:03.029Z View logs ↗

trueadm and others added 2 commits October 6, 2026 14:33
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]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
826be2d 2026-10-06T13:42:38.785Z View logs ↗

#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]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Unguarded method probe can throw
    • Wrapped the Function.prototype.toString.call and ARROW_HEAD.test inside ownMethodDep in a try/catch that returns the receiver on failure, matching the documented fail-closed contract.

Create PR

Or push these changes by commenting:

@cursor push 1bd19ba278
Preview (1bd19ba278)
diff --git a/packages/octane/src/method-dep.ts b/packages/octane/src/method-dep.ts
--- a/packages/octane/src/method-dep.ts
+++ b/packages/octane/src/method-dep.ts
@@ -90,8 +90,12 @@
 
 function ownMethodDep(receiver: object, method: unknown): unknown {
 	if (typeof method !== 'function') return method;
-	const source = Function.prototype.toString.call(method);
-	return ARROW_HEAD.test(source) && (source[0] === '(' || method.name !== 'async')
-		? method
-		: receiver;
+	try {
+		const source = Function.prototype.toString.call(method);
+		return ARROW_HEAD.test(source) && (source[0] === '(' || method.name !== 'async')
+			? method
+			: receiver;
+	} catch {
+		return receiver;
+	}
 }

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 527c9a4. Configure here.

Comment thread packages/octane/src/method-dep.ts Resolved
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]>
trueadm added a commit that referenced this pull request Oct 6, 2026
…main (#1819)

- weather framework (raw 132,546 -> 132,761, gzip 42,262 -> 42,381) and
  total (raw 154,697 -> 154,915, gzip 50,131 -> 50,253): #1818 makes
  inferred method-call dependencies track the receiver of a shared own
  method (#1788). `__methodDep` now reads an own function's source text to
  tell an arrow, which cannot see `this`, from a method; the weather app
  ships that helper. Measured: framework 132,729 raw / 42,349 gzip, total
  154,883 raw / 50,221 gzip. Brotli and app budgets still fit.
- deferred-hydration (raw 230,898 -> 230,880, gzip 72,349 -> 72,342): main
  measures 230,848 raw / 72,310 gzip, so #1771's downward ratchet fails test
  shard 1/4 on main and on every pull request based on it.

Values are measured + 32.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
octane-website Skipped Skipped Oct 6, 2026 2:35pm UTC
octane-website-mcp Skipped Skipped Oct 6, 2026 2:35pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website October 6, 2026 14:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 6, 2026 14:12 Inactive
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]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website October 6, 2026 14:35 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 6, 2026 14:35 Inactive
@trueadm
trueadm merged commit f50c128 into main Oct 6, 2026
34 checks passed
@trueadm
trueadm deleted the fix/method-dep-receiver branch October 6, 2026 14:59
trueadm added a commit that referenced this pull request Oct 6, 2026
…endencies (#1821)

* fix(octane): track the receiver of a shared own method in inferred dependencies

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]>

* fix(octane): shrink the arrow check in method dependencies

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]>

* fix(octane): keep a parenthesized arrow named async on its own identity

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]>

* fix(compiler): mark use() dependency probes as reads

#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]>

* fix(octane): fall back to the receiver when a method probe throws

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]>

* test(evals): pass arrow callbacks in the inferred-hook-deps grader

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]>

* fix(compiler): track an inherited method's receiver in use() memo dependencies

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]>

* fix(compiler): read use() memo dependencies through erased TypeScript 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]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

2 inactive deployments
Preview – octane-website — 337de879 Deployed Oct 6, 2026 by vercel[bot]
Preview – octane-website-mcp — 337de879 Deployed Oct 6, 2026 by vercel[bot]
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.

Inferred hook dependencies miss changes to a shared own-method receiver

1 participant