{"record":{"id":"628de4c5ff70524e","repo":"swc-project/swc","slug":"should-be-serializable","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/hygiene.rs","lineNumber":46,"sourceCode":"pub fn mark_is_descendant_of_proxy(\n    caller: &mut dyn runtime::Caller<'_>,\n    _env: &BaseHostEnvironment,\n    self_mark: u32,\n    ancestor: u32,\n    allocated_ptr: u32,\n) {\n    let self_mark = Mark::from_u32(self_mark);\n    let ancestor = Mark::from_u32(ancestor);\n\n    let return_value = self_mark.is_descendant_of(ancestor);\n\n    let context = VersionedSerializable::new(MutableMarkContext(\n        self_mark.as_u32(),\n        0,\n        return_value as u32,\n    ));\n    let serialized_bytes =\n        PluginSerializedBytes::try_serialize(&context).expect(\"Should be serializable\");\n\n    write_into_memory_view(caller, &serialized_bytes, |_, _| allocated_ptr);\n}\n\n#[cfg_attr(debug_assertions, tracing::instrument(level = \"info\", skip_all))]\npub fn mark_least_ancestor_proxy(\n    caller: &mut dyn runtime::Caller<'_>,\n    _env: &BaseHostEnvironment,\n    a: u32,\n    b: u32,\n    allocated_ptr: u32,\n) {\n    let a = Mark::from_u32(a);\n    let b = Mark::from_u32(b);\n\n    let return_value = Mark::least_ancestor(a, b).as_u32();\n\n    let context =","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_plugin_runner/src/imported_fn/hygiene.rs#L28-L64","documentation":"Host import backing a plugin's hygiene query `$hygiene::mark_is_descendant_of`. It computes `Mark::is_descendant_of` on the host, wraps the boolean plus marks into `MutableMarkContext`, and encodes it as versioned CBOR; the `.expect(\"Should be serializable\")` fires if encoding fails. Encoding three u32 fields cannot fail in a correct build, so hitting this panic signals a broken host/guest pairing (divergent swc_core schema) or memory corruption in the runner.","triggerScenarios":"A wasm plugin calls the mark_is_descendant_of host import while the plugin's swc_core guest bindings were compiled against a different version than the host swc_plugin_runner, or the cbor4ii encoder hits an internal error.","commonSituations":"Version drift between @swc/core and plugin builds after a partial upgrade; plugins compiled on a different swc_core minor with changed hygiene proxy ABI; rare encoder bugs in cbor4ii.","solutions":["Align the plugin's swc_core dependency with the version embedded in the installed @swc/core and rebuild","Upgrade @swc/core and every swc plugin atomically","Bisect plugins (disable each) to identify the incompatible binary","Report to swc-project/swc with exact @swc/core and swc_core versions if alignment does not fix it"],"exampleFix":"# before\n# plugin Cargo.toml: swc_core = \"=0.90.x\" ; host: @swc/core with swc_core 0.100.x\n\n# after\n# plugin Cargo.toml pinned to the host's version\nswc_core = \"=0.100.x\"\n# then: cargo build-wasi --release and redeploy the .wasm","handlingStrategy":"validation","validationCode":"// assert plugin/host compatibility before running transforms\nconst hostSwcCore = swcCoreEmbeddedVersion(); // from @swc/core release notes/lockfile\nconst pluginSwcCore = require('my-swc-plugin/swc_core_version.json').version;\nif (majorOrMinor(hostSwcCore) !== majorOrMinor(pluginSwcCore)) {\n  throw new Error(`hygiene proxy schema mismatch: host ${hostSwcCore} vs plugin ${pluginSwcCore}`);\n}","typeGuard":null,"tryCatchPattern":"// embed the transform and catch the unwind, mapping it to a plugin-disable decision:\nlet result = std::panic::catch_unwind(|| run_plugin_transform());\nif result.is_err() -> log 'plugin crashed, falling back to plugin-less transform' and retry without plugins","preventionTips":["Upgrade @swc/core and plugins together, never piecemeal","Keep a build matrix that exercises each plugin against the shipping compiler version","Expose the swc_core version in your plugin's package metadata for automated checks"],"tags":["plugin","wasm","cbor","serialization","hygiene","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-14T05:17:10.506Z"}