You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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::transform runs the full SWC -> Babel-AST conversion and HIR lowering on every file. fast_check::is_required (made conservative in fix(react-compiler): make fast check conservative #12105) is only used by the Node binding, not by transform, so files that infer/annotation mode can never compile still pay for conversion.
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
exportconstvalue=builder.next().next().next()/* ... ~1000 times ... */.next();
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.
Describe the bug
With
jsc.transform.reactCompilerenabled, 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 fix(react-compiler): make fast check conservative #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
Config
{ "jsc": { "transform": { "reactCompiler": true } } }Expected behavior
Files without JSX, hook calls or opt-in directives are left untouched in
infer/annotationmode, 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
transformonfast_check::is_requiredforinferandannotationmodes (allandsyntaxstay ungated). PR follows.stacker::maybe_grow, as the parser already does.Version
mainat 965c2df (swc_ecma_react_compiler25.0.0).