{"record":{"id":"35824eeaa9521790","repo":"swc-project/swc","slug":"unexpected-error-occurred-while-running-plugin-tra","errorCode":null,"errorMessage":"Unexpected error occurred while running plugin transform","messagePattern":"Unexpected error occurred while running plugin transform","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_plugin_runner/src/transform_executor.rs","lineNumber":97,"sourceCode":"        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)]\n    pub fn is_transform_schema_compatible(&mut self) -> Result<(), Error> {\n        #[cfg(any(","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_plugin_runner/src/transform_executor.rs#L79-L115","documentation":"Catch-all for plugin transforms that returned a failure flag with a PluginError variant other than SizeInteropFailure/Deserialize/Serialize (the '_' arm of the match in TransformExecutor). The specific error kind was not mapped, so no detail beyond this message survives; the raw error was consumed during matching.","triggerScenarios":"A plugin returning an uncommon PluginError variant - e.g. an explicit abort/unreachable variant emitted by plugin SDK macros - after instance.transform returned nonzero. Often the tail end of an assert or panic inside the guest converted into a PluginError.","commonSituations":"Plugin panics or debug_asserts compiled into release wasm, plugin SDK version drift introducing new error variants the host runner does not know, or guest code calling host APIs in the wrong order.","solutions":["Run the plugin host-side in debug mode or enable its logging so the guest's own error output (usually printed before returning) is visible","Align swc_core versions between host and plugin and rebuild","Reduce the input to a minimal reproduction and inspect the plugin code path around any expect/unwrap/panic"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust: the variant is unmapped - capture context and fail loudly\nmatch result {\n    Err(e) if e.to_string().contains(\"Unexpected error occurred while running plugin transform\") => {\n        tracing::error!(input = %file_name, plugin = %plugin_name, \"plugin returned unmapped error variant\");\n        return Err(e.context(format!(\"plugin {plugin_name} failed on {file_name}\")));\n    }\n    other => other,\n}","preventionTips":["Run plugins once in debug/verbose mode during development so guest-side panics print their own traces","Keep host and plugin swc_core aligned to avoid new error variants the host cannot name","Minify the failing input before reporting - maintainers need it"],"tags":["swc","plugins","wasm","catch-all","plugin-error"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}