swc-project/swc · error · anyhow::Error

Unexpected error occurred while running plugin transform

Error message

Unexpected error occurred while running plugin transform

What it means

The plugin returned bytes that deserialize into a PluginError variant the runner does not specifically match (anything other than SizeInteropFailure), so it reports a generic transform failure. The plugin failed in an unexpected way and the runner has no finer classification for it.

Solutions

  1. Run the plugin standalone or with plugin logs to find the root cause
  2. Disable the plugin to unblock the build and file a bug against it
  3. Extend the PluginError match in the runner to surface the new variant's details
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/swc_plugin_runner/src/transform_executor.rs:97 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/35824eeaa9521790. Report an issue: GitHub.

Appendix: source

Thrown at crates/swc_plugin_runner/src/transform_executor.rs:97

        let transformed_result = Arc::try_unwrap(self.transform_result)
            .map_err(|_| {
                anyhow!("Failed to unwrap Arc: other references to transform_result exist")
            })?
            .into_inner();
        let ret = PluginSerializedBytes::from_bytes(transformed_result);

        let ret = if returned_ptr_result == 0 {
            Ok(ret)
        } else {
            let err: PluginError = ret.deserialize()?.into_inner();
            match err {
                PluginError::SizeInteropFailure(msg) => Err(anyhow!(
                    "Failed to convert pointer size to calculate: {msg}"
                )),
                PluginError::Deserialize(msg) | PluginError::Serialize(msg) => {
                    Err(anyhow!("{msg}"))
                }
                _ => Err(anyhow!(
                    "Unexpected error occurred while running plugin transform"
                )),
            }
        };

        ret
    }

    /**
     * Check compile-time version of AST schema between the plugin and
     * the host. Returns true if it's compatible, false otherwise.
     *
     * Host should appropriately handle if plugin is not compatible to the
     * current runtime.
     */
    #[allow(unreachable_code)]
    pub fn is_transform_schema_compatible(&mut self) -> Result<(), Error> {
        #[cfg(any(

View on GitHub (pinned to 5176682b65)