{"record":{"id":"1e0a6ce352534843","repo":"swc-project/swc","slug":"should-be-serializable-1e0a6c","errorCode":null,"errorMessage":"Should be serializable","messagePattern":"Should be serializable","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/swc_plugin_runner/src/imported_fn/source_map.rs","lineNumber":62,"sourceCode":"    env: &SourceMapHostEnvironment,\n    byte_pos: u32,\n    should_include_source_file: i32,\n    allocated_ret_ptr: u32,\n) -> u32 {\n    let original_loc = env.source_map.lock().lookup_char_pos(BytePos(byte_pos));\n    let ret = VersionedSerializable::new(PartialLoc {\n        source_file: if should_include_source_file == 0 {\n            None\n        } else {\n            Some(original_loc.file)\n        },\n        line: original_loc.line,\n        col: original_loc.col.0,\n        col_display: original_loc.col_display,\n    });\n\n    let serialized_loc_bytes =\n        PluginSerializedBytes::try_serialize(&ret).expect(\"Should be serializable\");\n\n    allocate_return_values_into_guest(caller, allocated_ret_ptr, &serialized_loc_bytes);\n    1\n}\n\n#[cfg_attr(debug_assertions, tracing::instrument(level = \"info\", skip_all))]\npub fn doctest_offset_line_proxy(\n    _caller: &mut dyn runtime::Caller<'_>,\n    env: &SourceMapHostEnvironment,\n    orig: u32,\n) -> u32 {\n    env.source_map.lock().doctest_offset_line(orig as usize) as u32\n}\n\n#[allow(clippy::too_many_arguments)]\n#[cfg_attr(debug_assertions, tracing::instrument(level = \"info\", skip_all))]\npub fn merge_spans_proxy(\n    caller: &mut dyn runtime::Caller<'_>,","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_plugin_runner/src/imported_fn/source_map.rs#L44-L80","documentation":"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).","triggerScenarios":"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.","commonSituations":"Source-map-heavy plugins (error-formatters, coverage tools) run against an @swc/core newer/older than the plugin binary was built for.","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"],"exampleFix":"# before\n# @swc/core@new + source-map plugin wasm built on swc_core@old\n\n# after\n# rebuild plugin: cargo update -p swc_core --precise <host version> && cargo build-wasi --release","handlingStrategy":"validation","validationCode":"assertPluginHostAligned(pluginName, coreVersion); // sourcemap-lookup plugins included","typeGuard":null,"tryCatchPattern":"// contain native panics: run transform in a worker, retry without plugins on crash","preventionTips":["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"],"tags":["plugin","wasm","cbor","serialization","source-map","version-mismatch","panic"],"backgroundTag":"plugin-host-version-mismatch","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}