Repository navigation
fix: address React behavioral audit defects - #943
domgan-oai merged 11 commits into
Conversation
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 1c0cd39. Configure here.
Review against the audit's probe harness (head
|
| Area | IDs | Evidence |
|---|---|---|
| Compiler | A1 ternary-hole sibling order (10/11 cases; the 11th differs only in a probe artifact), A2 same-line whitespace (11/11 cases), A6 key coercion, A7 host key remount, A8 portal array/ternary/&& bodies, A10 <style dangerouslySetInnerHTML>, A11 parser-sensitive nesting (<p><div>, <div><tr>, <select><div>, <table><tr> incl. dynamic bindings, content now identical to React modulo Octane's comment anchors), A12 Suspense-transparent warming, A14 static <video muted>, A15 <html>/<head>/<body> compile, A17 precedence-less stylesheet stays in place |
children-order, children-extra, children-keys, effects-refs 4f/4g/4h, ctxerr-portal P6i2, dom-html, coord-nesting, susp-warm, dom-specials, ssr-elements |
| Runtime | B1 per-hook isPending (sched-pending P1: pB never flips), B2 transition errors reach the owner boundary / reportError (E9j/E9k), B3 render-time reducers and updaters, B6 root.unmount() drains cleanups before returning, B7 keyed inserts mount in tree order (focus race now picks the right element), B9 useDeferredValue stale indicator, B10 memo metadata no longer hoistable (__memo: false on the HOC), B11 keyed portals, B12 disabled-control mouse suppression, B13 handler snapshots incl. flushSync mid-dispatch, B14 custom-element event-name case |
hooks-transition2, ctxerr-errors, state-reducer, sched-more U1, effects-listorder 12f, susp-transition, api-exports, ctxerr-portal P6b, events-hosts, events-dynamic |
| Server/API | G1 string returns escaped (a<b&" → a<b&"), G2 <style> text raw, G3 <pre> newline guard, G4 buffered Suspense error renders the fallback + onError, G5 pending root throws instead of truncating, C1 renderable roots + second-position options, C3 document roots, B18 focus via focusin/focusout |
ssr-more, ssr-hooks, api-server, api-misc, events-hosts FOCUS |
The PR's new suites pass locally on this head: audit-hook-behavior (64), audit-events-portals (32), compiler-authored-hosts (58), server-renderable-contract (58), compatibility-exports (10), root-container-contract (24), host-update-contract (46), transition-held-audit (12), react-is/contract (7).
Blocker: the B8 hold-release rule regresses the documented useSuspenseQuery / router hold
handleSuspense now reads if (isTransition && …) and unconditionally calls releaseHeldTransition(state) for any non-transition re-suspend. The comment this replaced explained why the continuation existed: in the real useSuspenseQuery shape the query observer notifies on a later macrotask, after Octane's transition window has closed, so the re-render that re-suspends on the same in-flight fetch arrives at urgent priority. React keeps the old content there because its sync re-render happens on the committed (old-key) tree, which does not suspend; Octane has no separate work-in-progress tree, so the continuation was the compensating rule.
Three CI failures reproduce it, and I reproduced two locally on this head:
packages/tanstack-query/tests/conformance/transition-suspense.test.ts— both cases, "transition keeps prior content, no fallback flash (React parity)".packages/tanstack-router/tests/conformance/same-route-search.test.ts— "holds the current page while a same-route ?page change suspends (concurrent hold)":flashedPendingis nowtrue.examples/hacker-news/e2e/page-more-hold.spec.ts(CI, both tsrx and jsx): 30row-skeletons appear during the "more" transition.
The audit's B8 case (a user-initiated urgent setId('e') that suspends on a different thenable) is real and this PR fixes it, but the fix needs to distinguish the two shapes. A rule that satisfies both: keep the hold when the urgent render re-suspends on the thenable the hold is already waiting on (or one registered by the held attempt), and release only when it suspends on a new one. The audit's susp-basic probe (release on e) and the three suites above (continue on the same fetch) are the two oracles.
CI is red for other reasons too
- React parity shard 1/4:
packages/octane/src/public-types.tsreferencesReact.RefCallback,React.AriaAttributes,React.AriaRole,React.HTMLInputTypeAttribute,React.HTMLAttributeReferrerPolicy,React.HTMLAttributeAnchorTarget.@types/reactis already a hard dependency ofoctaneandjsx-runtime.d.tsalready imports it, so that is defensible, but three bindings still mapreactto the poison shim in their typetests:packages/formisch,packages/spring,packages/tiptap. The PR convertedapollo-clientandinertiato a source-import scan and missed these. Either update those three the same way or define the six aliases locally. Note the converted gates now check authored imports only, no longer the emitted declarations; worth a sentence in the doc. - lint:
packages/cli/src/data/octane-data.jsonis stale (pnpm cli:data), presumably missing@octanejs/react-is. - test shard 1/4:
packages/usehooks-ts/tests/state-hooks.test.ts"rejects step values outside the configured range". The port throws inside the functional updater (src/state.ts:117), which only ever threw synchronously because of the dispatch-time evaluation this PR removes. UpstreamuseStepvalidates before callingsetState, so the fix is to re-shape the port to upstream, not to keep the test. - website integration suite:
ssr-hydration.e2e.test.ts:1327expectsscrollY === 0on the first frame after a view-transition navigation and now sees 4560. I could not attribute this from the diff; it needs a look before merge since it is a user-visible regression in the website itself.
Should fix
- SSR carrier cost.
ssrHtml()allocates aServerHtmlper compiled component render, which the PR measures as a 7–9% SSR slowdown. Branding the compiled function in a moduleWeakSetat definition time gives the same guarantee without per-render allocation:hoist-non-react-staticscannot copy WeakSet membership, and a compiled body never returns user text unbranded, sotypeof out === 'string' && !COMPILED.has(fn)is the only check needed. SSR cold start is one of Octane's headline numbers; this seems worth trying before accepting the regression. - B4 is partial. Effects no longer fire for the discarded pass (the S1 half), but the child still renders once with the discarded state:
["init render 0","gc render 0","init render 5",…]vs React["init render 0","init render 5",…](state-render-phase2"self render-phase init on mount"). Either finish the replay or document the extra child render. createRoot(document.body)afterhydrateRoot(document, …)fails with "Target container is not a DOM element", which is misleading now that document roots exist; a nested-root or ownership message would be clearer.
Preserved-and-documented items I agree with
A4 opaque template children (descriptorChildren made public), A5 branch identity, A9 raw script bodies, B17 hidden suspended DOM and portals, C6 no forwardRef, the serialization-format differences, and the diagnostics scope. On B5 (passive effects stay post-paint) the contract text is now accurate and the misleading runtime comment is gone; that is a maintainer call rather than a review finding, but note the Radix port still carries its useEffectEvent workaround for it.
Process note
The PR body says the last full run had 55 failing tests. With the B8 rule reverted to a same-thenable continuation, the three gate updates, the cli data regeneration, and the useStep re-shape, the remaining red should be the website scroll assertion. Happy to re-run the probe set against a new head.
|
Addressed the follow-up findings in
Current-head CI is running. The broad local Node run reached 22,972 passing tests; each failure found there now passes its focused rerun, including native filesystem-watching checks outside the macOS sandbox. I am also addressing a newly measured unused-provider tree-shaking cost in a follow-up; the audit records current bundle and transition costs without claiming a speedup. |
|
Pushed
All four Node shards, browser integrations, package integrations/publication, typecheck, and Three/Lynx compatibility passed on the preceding head. CI is now running on this commit. |
|
Final validation is green on The final CI failure was console output mixed into the parity JSON stream. Commit All review threads are resolved, current main |
Second pass against
|
|
Addressed the second review in
Also revalidated the website locally on this commit: fresh authored production build, all 473 tests (396 unit plus 77 development/production SSR and browser integration checks), and the authored |
Final pass on
|
PR #943 moved spliceHead's empty-head early exit behind a full `body.indexOf('</head>')` so a document root gains an implicit <head>. Every fragment render with nothing to splice therefore scanned its complete response, which a CPU profile shows as the whole SSR throughput regression the audit attributed to the ServerHtml carrier; bundles with and without the carrier time the same. Decide the common case from the body's first bytes and return it unchanged; documents keep their implicit head. Pin the document/fragment contract, add negative escaping cases for wrappers and newline-sensitive hosts, and record the attribution in the audit document. Co-authored-by: Claude Fable 5.1 <[email protected]>
#946) * perf: keep form-action and transition graphs out of event-only bundles PR #943 let dispatchDelegated call the form-action submit handler directly, which made startTransition and the held-transition swap graph reachable from every bundle with delegated events. setFormAction, the only writer of $$formAction, now installs that handler through FORM_SUBMIT_DRIVER. The compiled setup checkpoint is emitted only when setup can schedule a render-phase self-update; passive built-in hooks and unshadowed pure globals cannot. Co-Authored-By: Claude Fable 5.1 <[email protected]> * perf: fail closed on callable-shaped sync-factory hook arguments A memo factory, state initializer, or reducer passed by reference can call a setter without a visible body. Treat every argument to a sync-factory hook that could be a function as an unclassified call so the setup checkpoint stays. Co-Authored-By: Claude Fable 5.1 <[email protected]> * perf: allow only non-invoking global namespace members in setup checkpoint analysis Array.from, JSON.parse/stringify callbacks, Object.groupBy, and similar can run user code by reference. Keep an explicit member allowlist and check the JSON callback positions like a hook factory. Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
…1335) The committed src/**/*.tsrx.d.ts files had drifted since #432: #1069 added a top-level JSX namespace to octane/jsx-runtime, and #943 changed memo's return type. Streamdown's types:check was never run by CI, so the drift went unnoticed. Regenerate the declarations and run `pnpm --dir packages/streamdown types:check` as a root `test` precheck alongside Visx's. Co-authored-by: Claude Opus 5.5 <[email protected]>
…output (#1586) Three gates that the weekly bench job and local Node 22 runs depend on had drifted from the code they observe. tsrx-component-graph counted warm plans with a regex for the `Object.assign(fn, { __warm: ... })` shape. #943 (44d50db) switched the compiler to `markWarm(fn, plan)`, so every graph counted zero and the opaque-cycle control failed. The harness now reads `markWarm` calls against the runtime import from the parsed output, and a ci:workflow:test case runs the cycle and chain controls against the current compiler on every PR. hook-store-composition's work gate required nonzero `appendSlotKey` calls on the nested lane. #1076 (1e12db7) moved composed hook paths into the cached `resolveHookPath`, leaving `appendSlotKey` only on the use() description path. The probe now counts `resolveHookPath`, the direct lane must compose nothing, and a ci:workflow:test case keeps the probe on the helper `resolveSlot` calls. behavior-root's destructured-props test pinned one read per getter. V8 12 (Node 22, including the 22.22.2 engines floor) also runs excluded keys' getters while copying an object rest, with no Octane code involved. The test now derives its oracle from one native evaluation of the authored pattern, so an extra snapshot read by Octane still fails on every engine. Co-authored-by: Claude Opus 5.5 <[email protected]>

Summary
Fix the confirmed compiler, runtime, DOM, hydration, SSR, and public API defects in the September 3 React 19.2.7 behavioral audit. The audit disposition maps every reported item to its fix or documented intentional Octane behavior.
@octanejs/react-isbinding pinned to the React 19.2.7 source and package artifact.Validation
Full CI passed on final commit
3f2636bac. The second review's router release-note request is addressed: the@octanejs/tanstack-routerpatch changeset, README guidance, and status notes document urgent same-route search updates and theuseDeferredValuemigration. The review reply also records the diagnostic dedupe comparison and local website verification. The PR is ready for human review..tsrxtypecheckpnpm sync, formatting, changeset checks, andgit diff --check; clean worktreeThe final CI fix makes the parity runner read a fresh JSON reporter file, so Vite/plugin console output cannot corrupt the report. Strict assertion/identity verification remains in place, and failed runs cannot publish or reuse successful evidence. Store and Dexie hooks preserve authored explicit slots alongside ambient hook adapters. Error 28 retains its published message; the expanded diagnostic uses new code 63. The new Store regression is recorded in its parity classification ledger.
Bugbot passed on
3f2636bacwith no findings. All published review threads are resolved; the maintainer review has a point-by-point response with regression evidence. Manual declaration providers preserve hoisting and cyclic imports while allowing unused providers and their dependencies to be removed from production bundles.Main at
e3194d536is included without conflicts. Human review is still required.Risk / follow-ups
This is a broad framework correction. Intentional Octane differences remain documented. Parent setup self-updates settle before child initialization; arbitrary late sibling side effects do not make template execution transactional.
Final hook/memo operation and source-allocation counters remain unchanged. Compiled fixtures grow by 713 minified bytes in each variant, and complete production bundles grow by 3,348 / 3,362 bytes gzip. The final paired transition sample measures 2.8 → 3.6 µs per cycle (29% on that minimal workload). Against the preceding adapter, the tree-shaking follow-up adds about 5.7–9.5 ns per manual-provider invocation in an isolated benchmark. The earlier serializer-only SSR measurement is about 7–9% slower, including the value carrier needed to distinguish text from serialized markup. These costs and measurement limits are documented in the audit.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Broad compiler, client runtime, SSR/hydration, and scheduling changes touch core framework contracts and many bindings; regressions could affect rendering, transitions, forms, and server output despite extensive audit-driven tests.
Overview
This PR closes the September 2026 React 19.2.7 behavioral audit with coordinated Octane core fixes and binding/example follow-ups, plus documentation and release notes that record what was fixed versus intentionally different.
Core and public surface (via changesets and
docs/divergence-audit-2026-09-03.md). Compiler and runtime behavior moves toward React-aligned observables: JSX ordering/whitespace/keys, template and SSR semantics, transitions and queued updates, native events and form controls, Suspense/hydration/SSR error handling, hook argument preservation through adapters, and migration exports (StrictMode,useFormState, React-named types). New framework error codes and hydration recovery reporting are wired through generated CLI data.New binding and port tooling. Adds
@octanejs/react-is(react-is 19.2.7) with status/inventory updates. React-library-port docs now allow a checkedupstream-types-absencecommand when upstream ships no TypeScript, instead of fabricating pristine/adapted type gates.Downstream integrations. Patch-level binding fixes (TanStack Router urgent same-route search store updates—Hacker News examples adopt
useDeferredValue; Testing Library focus/blur sequencing; Dexie/RxJS Symbol defaults and explicit hook slots; Query, Motion, Lynx, MCP, input-otp, usehooks-ts, etc.). Apollo and Formisch drop typetestreactpath stubs in favor of authored-source React import conformance scans. Benchmark reachability fixtures wait on visible Suspense commits and compile a wider JS/TS graph; minimal server render usescreateElement.Docs and evidence.
docs/differences-from-react.mdis expanded; binding counts bump to 107; many parity manifests refresh lockfile hashes; colorful/hook-form tests align with native focusout / delegated focus behavior.Reviewed by Cursor Bugbot for commit 3f2636b. Bugbot is set up for automated code reviews on this repo. Configure here.