# Behavior traces — facebook/react

> Canonical page: https://codevetter.com/unpack/react/behavior-traces

# Behavior traces — facebook/react

Scanned commit 59aff3e18cb5b3a336c280bbfa57ec37999511b9 (2026-09-18). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Three flows are worth walking: (1) client startup/first paint, from `createRoot` through the microtask scheduler into render and commit; (2) the compile flow, where Babel hands a function to either the TS `Pipeline.ts` or the Rust `pipeline.rs`; (3) the release flow, where a commit becomes npm artifacts. The commit phase in particular is a fixed three-pass sequence with `root.current = finishedWork` as the atomic swap point between mutation and layout, and passive effects flushed later. Each trace below names the functions in call order with line anchors.
- Startup trace: `createRoot(container, options)` → validate via `isValidContainer` → `createContainer(container, ConcurrentRoot, …, onUncaughtError, onCaughtError, onRecoverableError)` → `markContainerAsRoot(root.current, container)` → `listenToAllSupportedEvents(rootContainerElement)` → `new ReactDOMRoot(root)`. — [packages/react-dom/src/client/ReactDOMRoot.js#L171-L261](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-dom/src/client/ReactDOMRoot.js#L171-L261)
- First render trace: `root.render(children)` → `updateContainer` → `updateContainerImpl` → `requestUpdateLane(current)` → `createUpdate(lane)` → `enqueueUpdate(rootFiber, update, lane)` → `scheduleUpdateOnFiber(root, rootFiber, lane)`. — [packages/react-dom/src/client/ReactDOMRoot.js#L110-L136](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-dom/src/client/ReactDOMRoot.js#L110-L136) [packages/react-reconciler/src/ReactFiberReconciler.js#L341-L455](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberReconciler.js#L341-L455)
- Scheduling trace: `scheduleUpdateOnFiber` → `markRootUpdated(root, lane)` → `ensureRootIsScheduled(root)` → `ensureScheduleIsScheduled()` → `scheduleImmediateRootScheduleTask()` → (microtask) `processRootScheduleInMicrotask` → `scheduleTaskForRootDuringMicrotask` → `Scheduler_scheduleCallback(priorityLevel, performWorkOnRootViaSchedulerTask)`. — [packages/react-reconciler/src/ReactFiberWorkLoop.js#L1091](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberWorkLoop.js#L1091) [packages/react-reconciler/src/ReactFiberRootScheduler.js#L116-L200](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberRootScheduler.js#L116-L200) [packages/react-reconciler/src/ReactFiberRootScheduler.js#L259-L513](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberRootScheduler.js#L259-L513) [packages/react-reconciler/src/ReactFiberRootScheduler.js#L626-L695](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberRootScheduler.js#L626-L695)
- Render trace: `performWorkOnRoot(root, lanes, forceSync)` computes `shouldTimeSlice`, dispatches to `renderRootConcurrent` (line 2779) or `renderRootSync` (line 2623), then loops on the `RootExitStatus` — handling `RootInProgress` (yield, `startYieldTimer`), store inconsistency (re-render sync), and `RootErrored` (`getLanesToRetrySynchronouslyOnError` → `recoverFromConcurrentError`). — [packages/react-reconciler/src/ReactFiberWorkLoop.js#L1137-L1280](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberWorkLoop.js#L1137-L1280) [packages/react-reconciler/src/ReactFiberWorkLoop.js#L2623-L2790](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberWorkLoop.js#L2623-L2790)
- Component render trace: for each function component the reconciler calls `renderWithHooks`, which installs the mount-or-update dispatcher on `ReactSharedInternals.H`, invokes the component, then restores `ContextOnlyDispatcher`; `bailoutHooks` is the memoized fast path. — [packages/react-reconciler/src/ReactFiberHooks.js#L505-L570](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberHooks.js#L505-L570) [packages/react-reconciler/src/ReactFiberHooks.js#L655-L665](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberHooks.js#L655-L665) [packages/react-reconciler/src/ReactFiberHooks.js#L908-L945](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberHooks.js#L908-L945)
- Commit trace: `commitRoot` (line 3725) → `commitBeforeMutationEffects(root, finishedWork, lanes)` → `commitMutationEffects(root, finishedWork, lanes)` → `root.current = finishedWork` (the tree swap, line 4051) → `commitLayoutEffects(finishedWork, root, lanes)` → `flushSpawnedWork()`; passive effects run later via `flushPendingEffects` → `commitPassiveMountEffects`. — [packages/react-reconciler/src/ReactFiberWorkLoop.js#L3725-L4160](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberWorkLoop.js#L3725-L4160) [packages/react-reconciler/src/ReactFiberWorkLoop.js#L4655-L4800](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-reconciler/src/ReactFiberWorkLoop.js#L4655-L4800)
- Yield trace: inside a Scheduler task, `workLoop(initialTime)` drains the min-heap and stops when `shouldYieldToHost()` returns true (elapsed ≥ `frameInterval`); the continuation is re-armed by `schedulePerformWorkUntilDeadline()` through `setImmediate`/`MessageChannel`/`setTimeout`. — [packages/scheduler/src/forks/Scheduler.js#L193-L200](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/scheduler/src/forks/Scheduler.js#L193-L200) [packages/scheduler/src/forks/Scheduler.js#L456-L570](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/scheduler/src/forks/Scheduler.js#L456-L570)
- SSR trace: `renderToPipeableStream(children, options)` → `createRequestImpl` → `createRequest(...)` → `startWork(request)` (line 6370) → tasks retried through `retryTask`/`renderNode` → consumer calls `pipe(destination)` → `startFlowing(request, destination)` (line 6464) → `flushCompletedQueues` (line 6175); `abort(request, reason)` is the cancellation path (line 6557). — [packages/react-dom/src/server/ReactDOMFizzServerNode.js#L104-L160](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-dom/src/server/ReactDOMFizzServerNode.js#L104-L160) [packages/react-server/src/ReactFizzServer.js#L5327-L6560](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-server/src/ReactFizzServer.js#L5327-L6560)
- Server Action trace: HTTP POST FormData → `decodeAction(body, serverManifest)` → detect `$ACTION_REF_*` or `$ACTION_ID_*` → `decodeBoundActionMetaData` (for bound args) → `loadServerReference` → `resolveServerReference(bundlerConfig, id)` → `preloadModule` → `requireModule` → `bindArgs(fn, args)` → returned action `fn.bind(null, formData)`. — [packages/react-server/src/ReactFlightActionServer.js#L40-L162](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/packages/react-server/src/ReactFlightActionServer.js#L40-L162)
- TS compile trace: `compileFn` builds `Environment` from `findContextIdentifiers(func)`, then runs `lower(func, env)` → `PruneMaybeThrows` → `ValidateContextVariableLValues` → `MergeConsecutiveBlocks` → `SSA` → `EliminateRedundantPhi` → `ConstantPropagation` → `InferTypes` → `AnalyseFunctions` → `InferMutationAliasingEffects` → `DeadCodeElimination` → `InferMutationAliasingRanges` → `InferReactivePlaces` → `buildReactiveFunction` → `renameVariables`, logging each step through the `log(value)` callback. — [compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts#L119-L540](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts#L119-L540)
- Rust compile trace mirrors it: `compile_fn` → `react_compiler_lowering::lower` → `validate_context_variable_lvalues` → `validate_use_memo` → `enter_ssa` → `eliminate_redundant_phi` → `infer_types` → `analyse_functions` → `infer_mutation_aliasing_effects` → `infer_mutation_aliasing_ranges` → validations → `infer_reactive_places` → `infer_reactive_scope_variables` → scope alignment passes. — [compiler/crates/react_compiler/src/entrypoint/pipeline.rs#L37-L640](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/compiler/crates/react_compiler/src/entrypoint/pipeline.rs#L37-L640)
- The compiler is fault-tolerant rather than fail-fast: passes call `env.recordError(diagnostic)`, validation passes are wrapped in `env.tryRecord(() => pass(hir))`, and errors are aggregated at the end via `env.hasErrors()` / `env.aggregateErrors()` — `CompilerError.invariant()` is the only category that always throws. — [compiler/CLAUDE.md](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/compiler/CLAUDE.md) [compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts#L119-L200](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts#L119-L200)
- Rust bailout trace: `prefilter.ts` walks the Babel AST first and only forwards functions that are component/hook declarations or carry an opt-in directive, so the napi boundary is never crossed for ordinary functions. — [compiler/packages/babel-plugin-react-compiler-rust/src/prefilter.ts#L28-L155](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/compiler/packages/babel-plugin-react-compiler-rust/src/prefilter.ts#L28-L155) [compiler/packages/babel-plugin-react-compiler-rust/src/bridge.ts#L60-L130](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/compiler/packages/babel-plugin-react-compiler-rust/src/bridge.ts#L60-L130)
- Release trace: `yarn build` → `prebuild` links the compiler via `scripts/react-compiler/link-compiler.sh` → `build-all-release-channels.js` → `buildForChannel(channel)` spawns `scripts/rollup/build.js` → `processStable`/`processExperimental` rewrite versions from `ReactVersions.js` + short SHA → `scripts/release/publish.js` validates tags and publishes with OIDC. — [package.json#L122-L124](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/package.json#L122-L124) [scripts/rollup/build-all-release-channels.js#L24-L180](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/scripts/rollup/build-all-release-channels.js#L24-L180) [scripts/release/publish.js#L15-L60](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/scripts/release/publish.js#L15-L60)
- Error-minification trace: prod bundles emit `/*! <expected-error-format>"…"</expected-error-format>` markers; `yarn extract-errors` greps the `build` dir with `execSync('git --no-pager grep …')`, assigns the next free numeric code, and appends to `scripts/error-codes/codes.json` (~66 KB of registered messages). — [scripts/error-codes/extract-errors.js#L1-L55](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/scripts/error-codes/extract-errors.js#L1-L55) [scripts/error-codes/codes.json](https://github.com/facebook/react/blob/59aff3e18cb5b3a336c280bbfa57ec37999511b9/scripts/error-codes/codes.json)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
