swc-project/swc · critical
Should be serializable
Error message
Should be serializable
What it means
Host import behind a plugin's source-map position lookup (span/char-pos -> `PartialLoc`). It builds a `PartialLoc` (optional source-file name, line, col, col_display) and CBOR-encodes it for the guest; encode failure panics. All fields are plain integers and an Option<String>, so a healthy runtime cannot fail here - the panic means the host/guest plugin boundary is broken (swc_core schema divergence or memory corruption).
Source
Thrown at crates/swc_plugin_runner/src/imported_fn/source_map.rs:62
env: &SourceMapHostEnvironment,
byte_pos: u32,
should_include_source_file: i32,
allocated_ret_ptr: u32,
) -> u32 {
let original_loc = env.source_map.lock().lookup_char_pos(BytePos(byte_pos));
let ret = VersionedSerializable::new(PartialLoc {
source_file: if should_include_source_file == 0 {
None
} else {
Some(original_loc.file)
},
line: original_loc.line,
col: original_loc.col.0,
col_display: original_loc.col_display,
});
let serialized_loc_bytes =
PluginSerializedBytes::try_serialize(&ret).expect("Should be serializable");
allocate_return_values_into_guest(caller, allocated_ret_ptr, &serialized_loc_bytes);
1
}
#[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))]
pub fn doctest_offset_line_proxy(
_caller: &mut dyn runtime::Caller<'_>,
env: &SourceMapHostEnvironment,
orig: u32,
) -> u32 {
env.source_map.lock().doctest_offset_line(orig as usize) as u32
}
#[allow(clippy::too_many_arguments)]
#[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))]
pub fn merge_spans_proxy(
caller: &mut dyn runtime::Caller<'_>,View on GitHub (pinned to 5176682b65)
Solutions
- Rebuild the plugin with the swc_core version matching the installed @swc/core
- Upgrade @swc/core and plugins together
- Disable sourcemap-dependent plugin features as a stopgap
- Report upstream with versions if the crash remains on matched builds
Example fix
# before # @swc/core@new + source-map plugin wasm built on swc_core@old # after # rebuild plugin: cargo update -p swc_core --precise <host version> && cargo build-wasi --release
Defensive patterns
Strategy: validation
Validate before calling
assertPluginHostAligned(pluginName, coreVersion); // sourcemap-lookup plugins included
Try / catch
// contain native panics: run transform in a worker, retry without plugins on crash
Prevention
- Rebuild position/sourcemap plugins with every @swc/core upgrade
- Smoke-test sourcemap-emitting builds after upgrades
- Keep plugin wasm artifacts versioned by the swc_core they target
When it happens
Trigger: A wasm plugin performs source-map position lookups while its swc_core bindings and the host runner disagree on the CBOR schema, or the runner's encoder hits an internal error.
Common situations: Source-map-heavy plugins (error-formatters, coverage tools) run against an @swc/core newer/older than the plugin binary was built for.
Related errors
- Should be serializable
- Should be serializable
- Should able to be deserialized into string
- Should able to deserialize
- Should able to read memory from given ptr
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/1e0a6ce352534843.
Report an issue: GitHub.