Repository navigation
fix: stabilize Strong literal props and permit manual useMemo and useCallback - #2047
Conversation
Benchmark report🟢 No byte growth, 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 93 measured values. Public-import reachability bundles (bytes)No changes across 120 measured values. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit cafd81d. Configure here.
| // the literal binding. Keep receiver-owning methods/accessors fresh. | ||
| // Arrow properties cannot acquire the literal as their `this`. | ||
| if (includesLiteral && n.type !== 'ArrowFunctionExpression') blocked = true; | ||
| return; // does not run during render |
There was a problem hiding this comment.
Non-method functions break literal stability
Medium Severity
When Strong literal caching walks an object or array, any non-arrow FunctionExpression sets blocked, not only methods and accessors. Callbacks, IIFEs, and function ref entries do not receive that literal as this, but they still skip the cache. Unrelated renders then allocate a new ref array or context value and restart attachments or subscriptions.
Reviewed by Cursor Bugbot for commit cafd81d. Configure here.
Brings in #2047-#2051 (Strong literal stabilisation), #2054 (checked compiled boundaries and a compiled router entry), #2055/#2057 (Strong rejects descriptor APIs and .tsx/.jsx), #2056/#2060/#2061 (CLI Strong reports), #2062 (Strong in the website and devtools), #2065 (no browser-translation DOM accommodations) and Version Packages. Conflicts, resolved so main's behaviour lands on the redesign's commit model: - runtime.ts, #2065: setText keeps main's legacy host-only convention and the redesign's hydration writeText. The translator recovery is gone from renderText/commitText, setRenderText/commitSetText, commitHole, childTextHoleUpdate, recordHole and bindSignalChild; removeOnlyChildText still removes a committed Text at commit. resetOnlyChildHost and PENDING_HOST_TEXTS (which served only the host-only text writes) are deleted. - compile.js, #2065: text updates call setRenderText(_txt, v), commit functions setText(_txt, v), and commitHole takes no host. - runtime.server.ts, #2054: a compiled-only frame checks its output; ordinary frames keep the redesign's returned-value normalization. - codes.json: main's 344-346 (CompiledContext, CompiledOutlet) keep their numbers; the redesign's codes move to 347 (server boundary error), 348 (hydration protocol skew) and 349 (frontier rehome). Generated tables and CLI data are regenerated; docs/ssr.md names #348. Adaptations: - compiled-boundaries.test.ts: the server runs no error boundary (React's model), so an invalid CompiledOutlet under a catch-only @Try fails renderToString with the CompiledOutlet error; the client still shows the catch arm. - scripts/render-writers.mjs drops resetOnlyChildHost. Co-Authored-By: Claude Opus 5.5 <[email protected]>


Summary
Strong mode now keeps eligible ref arrays and literal component props stable on unrelated renders, and allows authors to use
useMemoanduseCallbackwith their own dependency lists.Closes #2045
Closes #2046
Why
<div ref={[frameRef, props.imageFrameRef]}>previously detached and reattached unchanged refs. An inline context value, includingconst context = { inline: node.type === "text" }, could restart subscriptions on unrelated changes. Strong mode also rejected manualuseMemoanduseCallback, leaving no direct way to control when a value or callback changes.Changes
useMemoanduseCallback, including aliases, with explicit arrays, inferred omitted/undefined deps, andnull. Preserve Strong effect, purity, and native-read policies; retire the obsolete manual-memo diagnostic and fix.useCallback: production must not hoist a capture-free function whose identity depends on authored deps.Validation
Final-head CI at cafd81d: all CI jobs and PR benchmarks passed. Includes all 4 Node test and React parity shards, Chromium, package/eval integrations, lint, typechecks, bundle gates, examples and provenance.
Final receiver regression: event mutation reproduces 4/4 failures before the fix; full dev/prod hook-cache suites pass 124/124 after it. Independent complexity review completed.
pnpm sync(existing exact-lock dependencies;PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN=falseavoids automatic reinstallation)Targeted compiler/runtime tests: 102 passed across hook cache, ownership and auto-calculation; separate mutation controls 8 passed.
Final useMemo/useCallback policy, runtime, native, diagnostic and migration suites: 1,130 tests passed (7 files, octane + octane-prod); CLI analyze 26 passed.
Before fix, all 4 useCallback cases failed the Strong ban; 2 capture-free aliased callback cases then failed specifically in production. Both regressions pass after the fix.
Before-fix regressions: 8/8 .tsrx/.tsx dev/prod ref/context tests failed for observable lifecycle churn; restoring the original ban makes all 6 manual memo tests fail.
Existing
benchmarks/template-call-memo/run.mjsbaseline and candidate: controls pass, all operation counts unchanged, Strong compiled 4770 B and bundled gzip 62944 B before/after. Compatibility unchanged (3817 B / 62471 B).Full changed-file formatting check with the repository's Prettier configuration.
Broad core octane/octane-prod local run: 45,451 tests passed; missing web3 dependencies and load/timeouts prevented a clean full run. Rerunning affected compiler/hydration/SSR suites at 2 workers passed 1,047/1,048; the sole remaining failure is an absolute 6 s timing bound on a 10,000-row, non-Strong plain JS parse (23 s on this machine).
Repository-wide
pnpm test,pnpm typecheck,pnpm format:check(targeted alternatives used).Risk / follow-ups
Automatic literal caching conservatively excludes receiver-capable regular functions, methods and accessors, even a function that does not actually use its receiver. Array entries can also be invoked as methods (
array[0]()); without deeper call-site proof they have the same escape. That can forgo automatic stability in some callback/ref cases. ExplicituseMemoremains available when the author deliberately wants to retain such a literal. Arrow properties and existing ref identifiers remain eligible.Ordinary JSX functions that have no proven hook/render ownership, deferred boundaries, server-only computations, and native/universal lowering keep their existing rules. Mutable local values that escape setup or are captured by callbacks remain live. The benchmark measures generated size and deterministic work, not browser latency or every consumer's whole bundle.
Provenance
agent-authored)Codex task · host
com-79386Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes Strong-mode compiler memoization and hook policy, affecting ref/context identity and when effects re-run; broad doc/tooling surface but behavior is covered by new tests.
Overview
Strong mode no longer bans
useMemoanduseCallback. Authors can use explicit dependency arrays, omit/undefinedfor inference, ornullfor every-render behavior; effects and imperative handles still enforce inferred deps (OCTANE_STRONG_EXPLICIT_DEPENDENCIES/OCTANE_STRONG_UNTRACKED_EFFECTscoped to those hooks). TheOCTANE_STRONG_MANUAL_MEMOdiagnostic, migration recipe, andoctane analyze --fixrewrites that stripped memo hooks are removed.The compiler adds
strongLiteralMemoso eligible object/array literals and ref arrays passed straight to props or refs keep stable identity when their tracked inputs are unchanged—including locals assigned before JSX. Literals that escape setup, are captured by callbacks, or are mutated stay on ordinary JavaScript lifetimes. Literal caching uses member-path dependencies instead of whole-binding identity.Docs, CLI/MCP catalogs, and tests are updated to match; new runtime/compiler tests cover ref churn, context subscriptions, mutable props, and manual memo/callback deps (including aliased
useCallbackin production).Reviewed by Cursor Bugbot for commit cafd81d. Bugbot is set up for automated code reviews on this repo. Configure here.