swc-project/swc · error
unable to access unknown nodes
Error message
unable to access unknown nodes
What it means
This wildcard arm closes the Pat match inside Param::babelify (function parameters) and compiles only when `--cfg swc_ast_unknown` is set — the cfg SWC plugin builds use to make swc_ecma_ast enums non_exhaustive for cross-version tolerance. If the Pat value holds a variant beyond Ident/Array/Rest/Object/Assign/Expr/Invalid that the linked swc_ecma_ast version does not define, the code panics with 'unable to access unknown nodes'. Like the other unknown-node panics, it signals an AST produced by a different swc version than the one linked in.
Source
Thrown at crates/swc_estree_compat/src/babelify/function.rs:94
base: ctx.base(self.span),
decorators: Some(self.decorators.babelify(ctx)),
..o.babelify(ctx)
})),
Pat::Assign(a) => BabelParam::Pat(Pattern::Assignment(AssignmentPattern {
base: ctx.base(self.span),
decorators: Some(self.decorators.babelify(ctx)),
..a.babelify(ctx)
})),
Pat::Expr(_) => panic!(
"illegal conversion: Cannot convert {:?} to BabelParam",
&self.pat
),
Pat::Invalid(_) => panic!(
"illegal conversion: Cannot convert {:?} to BabelParam",
&self.pat
),
#[cfg(swc_ast_unknown)]
_ => panic!("unable to access unknown nodes"),
}
}
}
impl Babelify for ParamOrTsParamProp {
type Output = BabelParam;
fn babelify(self, ctx: &Context) -> Self::Output {
match self {
ParamOrTsParamProp::TsParamProp(p) => BabelParam::TSProp(p.babelify(ctx)),
ParamOrTsParamProp::Param(p) => p.babelify(ctx),
#[cfg(swc_ast_unknown)]
_ => panic!("unable to access unknown nodes"),
}
}
}
View on GitHub (pinned to 5176682b65)
Solutions
- Unify swc versions: `cargo tree -i swc_ecma_ast` must show one version; update via swc_core
- Upgrade swc_estree_compat alongside swc_ecma_ast so the new Pat variant is covered
- Rebuild the plugin/wasm boundary against the host's swc release
- Use catch_unwind around babelify to degrade to a per-file error during migration
Defensive patterns
Strategy: try-catch
Type guard
fn param_pat_known(p: &Pat) -> bool {
matches!(
p,
Pat::Ident(_) | Pat::Array(_) | Pat::Rest(_) | Pat::Object(_) | Pat::Assign(_) | Pat::Expr(_) | Pat::Invalid(_)
)
} Try / catch
let out = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| program.babelify(&ctx)))
.map_err(|_| anyhow::anyhow!("babelify failed: swc_ecma_ast version mismatch (unknown Pat)"))?; Prevention
- Single swc version rule: check `cargo tree -i swc_ecma_ast` in CI
- Upgrade swc_estree_compat and swc_ecma_ast atomically
- Rebuild plugin/wasm binaries with host upgrades
- Include parameter-heavy fixtures in smoke tests
When it happens
Trigger: A function parameter's Pat enum arriving from a newer/older swc_ecma_ast across a plugin ABI or mixed-version Cargo graph, carrying a variant this build cannot name.
Common situations: Plugin host/plugin version drift; partial swc upgrades leaving swc_estree_compat behind; wasm binaries cached from an older build.
Related errors
- unable to access unknown nodes
- unable to access unknown nodes
- unable to access unknown nodes
- illegal conversion: Cannot convert {:?} to BabelParam
- unable to access unknown nodes
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/0cda59da45d8069b.
Report an issue: GitHub.