{"record":{"id":"7d570939ed853098","repo":"Pumpkin-MC/Pumpkin","slug":"failed-to-add-player-resource","errorCode":null,"errorMessage":"failed to add player resource","messagePattern":"failed to add player resource","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs","lineNumber":915,"sourceCode":"            self.cancelled = data.cancelled;\n        }\n    }\n\n    fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {\n        match event {\n            Event::BlockFertilizeEvent(_) => {\n                panic!(\"Cannot construct BlockFertilizeEvent from WASM\")\n            }\n            _ => panic!(\"unexpected event type\"),\n        }\n    }\n}\n\nimpl ToFromWasmEvent for BlockMultiPlaceEvent {\n    fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {\n        let player = state\n            .add_player(self.player.clone())\n            .expect(\"failed to add player resource\");\n        let target_world = state\n            .add_world(self.world.clone())\n            .expect(\"failed to add world resource\");\n        let placed_blocks = self\n            .placed_blocks\n            .iter()\n            .map(|(pos, id)| (to_wasm_block_position(*pos), id.as_u16()))\n            .collect();\n        Event::BlockMultiPlaceEvent(BlockMultiPlaceEventData {\n            player,\n            target_world,\n            placed_blocks,\n            cancelled: self.cancelled,\n        })\n    }\n\n    fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {\n        cleanup_event(&event, state);","sourceCodeStart":897,"sourceCodeEnd":933,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs#L897-L933","documentation":"An `.expect(\"failed to add player resource\")` in BlockMultiPlaceEvent::to_wasm_event. When converting the native event to its WASM representation, the player's Arc reference must be registered in PluginHostState's resource table; add_player returned None/Err, so the conversion aborts.","triggerScenarios":"Serializing a BlockMultiPlaceEvent for a WASM plugin when the player resource cannot be inserted into the host state table (e.g. player already freed or table in a bad state).","commonSituations":"Firing a multi-block-place event during teardown or for an already-removed player; resource-table exhaustion or state bug in the WASM host.","solutions":["Ensure the player entity is still alive/valid when the event fires","Inspect PluginHostState::add_player for why insertion failed","Update server if this occurs during normal gameplay (likely a host-state bug)","Avoid dispatching this event to WASM plugins for despawned players"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// guard before dispatching to WASM\nif !player.is_alive() || player.is_removed() { skip_wasm_dispatch(event); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only dispatch events for live players to WASM plugins","Check resource-table insertion errors instead of expect in host code","Test event dispatch during player disconnect/teardown scenarios"],"tags":["panic","wasm","resource-table","events"],"backgroundTag":"internal-invariant-violation","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"}