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:
swc_ecma_react_compiler::transformruns 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 bytransform, so files thatinfer/annotationmode can never compile still pay for conversion.convert_exprinconvert_ast.rs(and its reverse) recurse once per chain link withoutstacker. 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
export const value = builder.next().next().next() /* ... ~1000 times ... */ .next();Config
{ "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
transformonfast_check::is_requiredforinferandannotationmodes (allandsyntaxstay 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).
Source: swc-project/swc