Pumpkin-MC/Pumpkin · error · PluginInitError

Failed to load plugin as component

Error message

Failed to load plugin as component: {0}

What it means

This is `PluginInitError::ComponentNewFailed`, wrapping a `wasmtime::Error`. The plugin bytes could not be compiled/loaded as a WASM component (`wasmtime::component::Component::new` failed). Pumpkin treats every plugin as a component; an invalid binary, wrong target, or a decoder error lands here.

Solutions

  1. Rebuild the plugin targeting wasm32-wasip2 so it is a real component
  2. Validate the file with `wasm-tools component wit plugin.wasm` or `file plugin.wasm`
  3. Re-download the plugin — the file may be truncated (compare checksum)
  4. Rebuild Pumpkin if its wasmtime version predates the component encoding used by the plugin

Example fix

// before: cargo build --target wasm32-unknown-unknown
// after:  cargo build --target wasm32-wasip2 && wasm-tools validate target/.../plugin.wasm
Defensive patterns

Strategy: validation

Validate before calling

// verify the artifact is a component before handing it to wasmtime
if !bytes.starts_with(&[0x0d, 0x00, 0x01, 0x00]) { bail!("not a WASM component"); }

Type guard

fn is_component(bytes: &[u8]) -> bool { bytes.len() > 4 && bytes[0..4] == [0x0d, 0x00, 0x01, 0x00] }

Try / catch

match init::component_new(&engine, &bytes) {
    Err(PluginInitError::ComponentNewFailed(e)) => eprintln!("invalid plugin component: {e} — rebuild with wasm32-wasip2"),
    other => other,
}

Prevention

When it happens

Trigger: Calling `Component::new(&engine, bytes)` with bytes that are not a valid component — a core wasm module, a corrupted/truncated download, or a component using unsupported WIT/wasmtime features.

Common situations: Renaming a .wasm core module to look like a plugin, partially downloaded file, plugin built with a toolchain producing components incompatible with the server's wasmtime version.

Related errors


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/bd53e110c9626f2a. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/mod.rs:31

pub mod args;
pub mod concurrent_store;
pub mod logging;
pub mod signature;
pub mod state;
pub mod wit;

#[derive(Error, Debug)]
pub enum PluginInitError {
    #[error("Engine creation failed: {0}")]
    EngineCreationFailed(wasmtime::Error),
    #[error("Failed to setup linker: {0}")]
    LinkerSetupFailed(wasmtime::Error),
    #[error("Plugin is built against a different API version: {0}")]
    ApiVersionMismatch(wasmtime::Error),
    #[error("Failed to read plugin file: {0}")]
    FileReadFailed(std::io::Error),
    #[error("Failed to load plugin as component: {0}")]
    ComponentNewFailed(wasmtime::Error),
    #[error("Failed to create cache data for plugin: {0}")]
    ComponentCacheSerializeFailed(wasmtime::Error),
    #[error("Failed to write cache file for plugin: {0}")]
    ComponentCacheWriteFailed(std::io::Error),
    #[error("Failed to instantiate plugin: {0}")]
    InstantiationFailed(wasmtime::Error),
    #[error("Calling `init_plugin` failed: {0}")]
    CallInitPluginFailed(wasmtime::Error),
    #[error("Calling `get_metadata` failed: {0}")]
    CallGetMetadataFailed(wasmtime::Error),
    #[error("Failed to get absolute path: {0}")]
    PathResolutionFailed(std::io::Error),
    #[error("Failed to create cache: {0}")]
    CacheCreationFailed(wasmtime::Error),
}

#[derive(Clone, Copy, Default)]

View on GitHub (pinned to 8d4639e25a)