Pumpkin-MC/Pumpkin · critical
failed to add world resource
Error message
failed to add world resource
What it means
An `.expect("failed to add world resource")` in BlockMultiPlaceEvent::to_wasm_event. The event's world Arc must be registered as a WASM resource in PluginHostState; add_world failed, so conversion to the WASM event panics.
Solutions
- Check that the world is still loaded when the event is dispatched
- Inspect PluginHostState::add_world for the insertion failure cause
- Skip WASM dispatch of events tied to unloading worlds
- Update to a server version fixing the host-state handling
Defensive patterns
Strategy: validation
Validate before calling
// guard before dispatching to WASM
if !world.is_loaded() || world.is_unloading() { skip_wasm_dispatch(event); } Prevention
- Suppress WASM event dispatch for worlds being unloaded
- Handle add_world failures gracefully in host state code
- Cover world-unload-during-event scenarios in tests
When it happens
Trigger: Serializing a BlockMultiPlaceEvent for WASM plugins when the world reference cannot be added to the host resource table.
Common situations: Event fired while its world is being unloaded/removed; resource-table state corruption in the WASM host; version-skew between event producers and the wasm host.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- failed to add player resource
- failed to add text-component resource
- Cannot construct BlockFertilizeEvent from WASM
- unexpected event type
- Cannot construct BlockMultiPlaceEvent from WASM
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/6b2bf6e05f048a06.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs:918
fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
match event {
Event::BlockFertilizeEvent(_) => {
panic!("Cannot construct BlockFertilizeEvent from WASM")
}
_ => panic!("unexpected event type"),
}
}
}
impl ToFromWasmEvent for BlockMultiPlaceEvent {
fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {
let player = state
.add_player(self.player.clone())
.expect("failed to add player resource");
let target_world = state
.add_world(self.world.clone())
.expect("failed to add world resource");
let placed_blocks = self
.placed_blocks
.iter()
.map(|(pos, id)| (to_wasm_block_position(*pos), id.as_u16()))
.collect();
Event::BlockMultiPlaceEvent(BlockMultiPlaceEventData {
player,
target_world,
placed_blocks,
cancelled: self.cancelled,
})
}
fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {
cleanup_event(&event, state);
if let Event::BlockMultiPlaceEvent(data) = event {
self.cancelled = data.cancelled;
}View on GitHub (pinned to 8d4639e25a)