Pumpkin-MC/Pumpkin · error
failed to add player resource
Error message
failed to add player resource
What it means
to_wasm_event for EntityTameEvent calls PluginHostState::add_player to register the taming owner (an Arc<Player>) in the WASM resource table and .expect()s success; if the resource cannot be inserted, the host panics with "failed to add player resource". add_player can fail when the linear-component resource table cannot allocate a new handle (e.g. table limits) or the store/state is in a bad state, so the tame event can never be serialized for the guest.
Solutions
- Check whether add_player failures correlate with resource-table exhaustion; ensure consume_player/cleanup_event runs for every added player resource
- Update wasmtime/pumpkin to a version that grows the resource table or returns errors gracefully
- Ensure the plugin's store/instance is alive and healthy when entity events fire
- Replace the .expect with logged error + event skip so one bad conversion doesn't kill the server thread
Example fix
// before
let owner = state
.add_player(self.owner.clone())
.expect("failed to add player resource");
// after
let owner = match state.add_player(self.owner.clone()) {
Ok(o) => o,
Err(e) => {
log::error!("skipping EntityTameEvent: add_player failed: {e}");
return Event::NoEvent; // or propagate an error
}
}; Defensive patterns
Strategy: try-catch
Validate before calling
// before firing the event, ensure the state/store is usable
if state.resource_table_is_full() { log::warn!("player resource table full; skipping EntityTameEvent"); return; } Type guard
fn can_add_player(state: &PluginHostState, p: &Arc<Player>) -> bool { !state.is_torn_down() && state.player_table_has_capacity() } Try / catch
match state.add_player(owner.clone()) {
Ok(h) => build_event(h),
Err(e) => log::error!("EntityTameEvent dropped: {e}"), // don't .expect in hot event paths
} Prevention
- Always call consume_player/cleanup_event for every added player resource to avoid table exhaustion
- Avoid .expect on resource-table inserts in event hot paths
- Monitor resource-table growth on long-running servers
- Keep wasmtime updated for resource-table fixes
When it happens
Trigger: An EntityTameEvent fires and state.add_player(self.owner) returns Err — resource-table allocation failure in the wasmtime instance, calling with a PluginHostState whose store is torn down, or a resource handle leak exhausting the table over many events.
Common situations: Long-running servers where player/bossbar resources are added without cleanup, eventually hitting wasmtime resource-table limits; plugins crashing mid-event leaving the host state inconsistent.
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 world resource
- failed to add world resource
- failed to add player resource
- unexpected event type
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/4ba6b5b89fbedfb8.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/entity.rs:524
fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
match event {
Event::EntityShootBowEvent(data) => Self {
entity_id: data.entity_id,
weapon_name: data.weapon_name,
force: data.force,
cancelled: data.cancelled,
},
_ => panic!("unexpected event type"),
}
}
}
impl ToFromWasmEvent for crate::plugin::api::events::entity::entity_tame::EntityTameEvent {
fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {
let owner = state
.add_player(self.owner.clone())
.expect("failed to add player resource");
Event::EntityTameEvent(EntityTameEventData {
entity_id: self.entity_id,
owner,
cancelled: self.cancelled,
})
}
fn from_wasm_event(event: Event, state: &mut PluginHostState) -> Self {
match event {
Event::EntityTameEvent(data) => Self {
entity_id: data.entity_id,
owner: consume_player(state, &data.owner),
cancelled: data.cancelled,
},
_ => panic!("unexpected event type"),
}
}
}View on GitHub (pinned to 8d4639e25a)