{"record":{"id":"bd53e110c9626f2a","repo":"Pumpkin-MC/Pumpkin","slug":"failed-to-load-plugin-as-component-0","errorCode":null,"errorMessage":"Failed to load plugin as component: {0}","messagePattern":"Failed to load plugin as component: (.+?)","errorType":"exception","errorClass":"PluginInitError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin/src/plugin/loader/wasm/wasm_host/mod.rs","lineNumber":31,"sourceCode":"\npub mod args;\npub mod concurrent_store;\npub mod logging;\npub mod signature;\npub mod state;\npub mod wit;\n\n#[derive(Error, Debug)]\npub enum PluginInitError {\n    #[error(\"Engine creation failed: {0}\")]\n    EngineCreationFailed(wasmtime::Error),\n    #[error(\"Failed to setup linker: {0}\")]\n    LinkerSetupFailed(wasmtime::Error),\n    #[error(\"Plugin is built against a different API version: {0}\")]\n    ApiVersionMismatch(wasmtime::Error),\n    #[error(\"Failed to read plugin file: {0}\")]\n    FileReadFailed(std::io::Error),\n    #[error(\"Failed to load plugin as component: {0}\")]\n    ComponentNewFailed(wasmtime::Error),\n    #[error(\"Failed to create cache data for plugin: {0}\")]\n    ComponentCacheSerializeFailed(wasmtime::Error),\n    #[error(\"Failed to write cache file for plugin: {0}\")]\n    ComponentCacheWriteFailed(std::io::Error),\n    #[error(\"Failed to instantiate plugin: {0}\")]\n    InstantiationFailed(wasmtime::Error),\n    #[error(\"Calling `init_plugin` failed: {0}\")]\n    CallInitPluginFailed(wasmtime::Error),\n    #[error(\"Calling `get_metadata` failed: {0}\")]\n    CallGetMetadataFailed(wasmtime::Error),\n    #[error(\"Failed to get absolute path: {0}\")]\n    PathResolutionFailed(std::io::Error),\n    #[error(\"Failed to create cache: {0}\")]\n    CacheCreationFailed(wasmtime::Error),\n}\n\n#[derive(Clone, Copy, Default)]","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/plugin/loader/wasm/wasm_host/mod.rs#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rebuild the plugin targeting wasm32-wasip2 so it is a real component","Validate the file with `wasm-tools component wit plugin.wasm` or `file plugin.wasm`","Re-download the plugin — the file may be truncated (compare checksum)","Rebuild Pumpkin if its wasmtime version predates the component encoding used by the plugin"],"exampleFix":"// before: cargo build --target wasm32-unknown-unknown\n// after:  cargo build --target wasm32-wasip2 && wasm-tools validate target/.../plugin.wasm","handlingStrategy":"validation","validationCode":"// verify the artifact is a component before handing it to wasmtime\nif !bytes.starts_with(&[0x0d, 0x00, 0x01, 0x00]) { bail!(\"not a WASM component\"); }","typeGuard":"fn is_component(bytes: &[u8]) -> bool { bytes.len() > 4 && bytes[0..4] == [0x0d, 0x00, 0x01, 0x00] }","tryCatchPattern":"match init::component_new(&engine, &bytes) {\n    Err(PluginInitError::ComponentNewFailed(e)) => eprintln!(\"invalid plugin component: {e} — rebuild with wasm32-wasip2\"),\n    other => other,\n}","preventionTips":["Build plugins with --target wasm32-wasip2","Validate with `wasm-tools validate` in CI before publishing","Re-download truncated/corrupt plugin files"],"tags":["wasmtime","component","wasm","plugin"],"backgroundTag":"module-init-failed","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}