{"record":{"id":"00086a5d0b194134","repo":"swc-project/swc","slug":"failed-to-unwrap-arc-other-references-to-transfor","errorCode":null,"errorMessage":"Failed to unwrap Arc: other references to transform_result exist","messagePattern":"Failed to unwrap Arc: other references to transform_result exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_plugin_runner/src/transform_executor.rs","lineNumber":81,"sourceCode":"        let returned_ptr_result = self.instance.transform(\n            guest_program_ptr.0,\n            guest_program_ptr.1,\n            unresolved_mark.as_u32(),\n            should_enable_comments_proxy,\n        )?;\n\n        self.instance\n            .caller()?\n            .free(guest_program_ptr.0, guest_program_ptr.1)?;\n        self.instance.cleanup()?;\n\n        // Construct serialized struct from raw bytes.\n        // Since we have finished transformation, it's safe to fetch the data from\n        // 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                )),","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_plugin_runner/src/transform_executor.rs#L63-L99","documentation":"After a plugin transform finishes, the runner drops the plugin instance and calls Arc::try_unwrap on transform_result to take exclusive ownership of the serialized output. If other Arc clones are still alive the unwrap fails and the runner reports this error instead of the plugin result — a reference-counting/lifetime bug in plugin execution, not bad user input.","triggerScenarios":"Thrown at crates/swc_plugin_runner/src/transform_executor.rs:81 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure all other Arc clones (instance handles, cached results) are dropped before unwrapping","Check Arc::strong_count first and clone the inner value when refs remain","Treat as an internal bug: transform_result should not be shared past cleanup"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}