#12423·swc

reactCompiler: stack overflow on long call chains; fast_check::is_required unused by transform

Author: BleedingDevCreated Sep 27, 2026Updated Sep 27, 2026

Describe the bug

With jsc.transform.reactCompiler enabled, SWC overflows the stack on files that contain long member-call chains (for example generated query builders), even when the file has no React code at all.

Two things combine:

  1. swc_ecma_react_compiler::transform runs the full SWC -> Babel-AST conversion and HIR lowering on every file. fast_check::is_required (made conservative in #12105) is only used by the Node binding, not by transform, so files that infer/annotation mode can never compile still pay for conversion.
  2. convert_expr in convert_ast.rs (and its reverse) recurse once per chain link without stacker. On a 2 MiB thread (the default for spawned threads, e.g. in rspack workers) a debug build of the crate tests overflows at about 40 links; we saw release builds (via rspack) overflow at roughly 165 links.

Input code

javascript
export const value = builder.next().next().next() /* ... ~1000 times ... */ .next();

Config

json
{ "jsc": { "transform": { "reactCompiler": true } } }

Expected behavior

Files without JSX, hook calls or opt-in directives are left untouched in infer/annotation mode, and long chains in real components do not abort the process.

Actual behavior

thread '<unknown>' has overflowed its stack / fatal runtime error: stack overflow, aborting.

Proposed fix

  • Gate transform on fast_check::is_required for infer and annotation modes (all and syntax stay ungated). PR follows.
  • Separately, wrap the recursive expression conversion in stacker::maybe_grow, as the parser already does.

Version

main at 965c2dfe2e (swc_ecma_react_compiler 25.0.0).