{"record":{"id":"7333e39605dfc1b1","repo":"swc-project/swc","slug":"msg","errorCode":null,"errorMessage":"{msg}","messagePattern":"\\{msg\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_plugin_runner/src/transform_executor.rs","lineNumber":95,"sourceCode":"        // Arc<Mutex<T>>\n        drop(self.instance);\n        let transformed_result = Arc::try_unwrap(self.transform_result)\n            .map_err(|_| {\n                anyhow!(\"Failed to unwrap Arc: other references to transform_result exist\")\n            })?\n            .into_inner();\n        let ret = PluginSerializedBytes::from_bytes(transformed_result);\n\n        let ret = if returned_ptr_result == 0 {\n            Ok(ret)\n        } else {\n            let err: PluginError = ret.deserialize()?.into_inner();\n            match err {\n                PluginError::SizeInteropFailure(msg) => Err(anyhow!(\n                    \"Failed to convert pointer size to calculate: {msg}\"\n                )),\n                PluginError::Deserialize(msg) | PluginError::Serialize(msg) => {\n                    Err(anyhow!(\"{msg}\"))\n                }\n                _ => Err(anyhow!(\n                    \"Unexpected error occurred while running plugin transform\"\n                )),\n            }\n        };\n\n        ret\n    }\n\n    /**\n     * Check compile-time version of AST schema between the plugin and\n     * the host. Returns true if it's compatible, false otherwise.\n     *\n     * Host should appropriately handle if plugin is not compatible to the\n     * current runtime.\n     */\n    #[allow(unreachable_code)]","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_plugin_runner/src/transform_executor.rs#L77-L113","documentation":"The plugin transform failed and the returned PluginError is Deserialize(msg) or Serialize(msg): the plugin could not serialize its transformed AST for the host, or the bytes it produced could not be deserialized, and {msg} is the underlying rkyv/serialization error text. This is the classic host/plugin AST schema mismatch signature.","triggerScenarios":"Plugin built with a swc_core whose rkyv-derived AST layout differs from the host's - any serialized-bytes round trip then fails with a deserialize/serialize error inside the plugin; also possible on plugins that mutate the AST into an inconsistent state before serialization.","commonSituations":"Upgrading @swc/core (host) without rebuilding local plugins, plugins built on nightly swc_core, or publishing a plugin compiled months earlier against current tooling.","solutions":["Pin the plugin's swc_core to the same version the host uses and rebuild the plugin wasm","Confirm with cargo tree which swc_core each side resolved; mismatched minor versions are enough","If versions match, reproduce with a minimal input and report the {msg} payload upstream - it may indicate a genuine serialization bug"],"exampleFix":"# before: plugin on old swc_core, host on new\n# plugin Cargo.toml\nswc_core = \"8\"\n\n# after\nswc_core = \"10\"  # exactly match the host, then rebuild the wasm","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust: distinguish schema-mismatch serialization failures from real plugin bugs\nlet msg = format!(\"{e:#}\");\nif msg.contains(\"failed to serialize\") || msg.contains(\"failed to deserialize\") || msg.contains(\"Serialize\") {\n    return Err(anyhow!(\"plugin/host swc_core version mismatch (serialize/deserialize failed); align versions and rebuild the plugin\"));\n}","preventionTips":["Lock swc_core to one version across the workspace (cargo update -p swc_core --precise ...)","Rebuild and republish plugins whenever the host's swc_core minor bumps","Watch for 'Deserialize/Serialize' messages after upgrades - treat them as version drift first, bugs second"],"tags":["swc","plugins","wasm","serialization","version-mismatch","rkyv"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}