{"record":{"id":"0529d77edbf4ee58","repo":"Pumpkin-MC/Pumpkin","slug":"wasm-chunk-generation-phase-failed-for-generator","errorCode":null,"errorMessage":"Wasm chunk generation phase failed for generator {generator_id}: {error}","messagePattern":"Wasm chunk generation phase failed for generator (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/world.rs","lineNumber":2323,"sourceCode":"                        let (buffer_resource, buffer_rep) = guest.with(|mut store| {\n                            let resource = store.data_mut().add_chunk_buffer(chunk_buffer)?;\n                            let rep = resource.rep();\n                            Ok::<_, wasmtime::Error>((resource, rep))\n                        })?;\n                        let result = guest\n                            .call(function, (generator_id, phase, buffer_resource))\n                            .await;\n                        guest.with(|mut store| {\n                            let _ = store.data_mut().resource_table.delete::<\n                                crate::plugin::loader::wasm::wasm_host::state::ChunkBufferResource,\n                            >(wasmtime::component::Resource::new_own(buffer_rep));\n                        });\n                        result\n                    })\n                })\n                .await;\n            if let Err(error) = result {\n                panic!(\"Wasm chunk generation phase failed for generator {generator_id}: {error}\");\n            }\n        };\n\n        // Tokio runtime probably won't be available since chunk gen happens on rayon\n        if tokio::runtime::Handle::try_current().is_ok() {\n            tokio::task::block_in_place(|| {\n                self.server.runtime.block_on(run);\n            });\n        } else {\n            self.server.runtime.block_on(run);\n        }\n    }\n}\n\nimpl pumpkin_world::generation::generator::CustomChunkGenerator for WasmChunkGenerator {\n    fn dimension(&self) -> &pumpkin_data::dimension::Dimension {\n        &self.dimension\n    }","sourceCodeStart":2305,"sourceCodeEnd":2341,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/world.rs#L2305-L2341","documentation":"When a WASM world-generator plugin completes a chunk-generation phase, the host awaits the result and panics if it returned an Err. The panic message embeds the generator's ID and the underlying error, and it aborts the chunk-generation task (running on the rayon pool). This converts any generator failure — plugin trap, WIT error, or host callback failure — into an unrecoverable panic for that generation task.","triggerScenarios":"A plugin's chunk generation phase (init/populate/finish styled phases invoked per generator_id) returns an error: the WASM module traps, a guest export returns Err, or a host-side callback invoked during generation fails; generation runs off the tokio runtime on rayon, so the panic propagates through the chunk-gen worker.","commonSituations":"A buggy worldgen plugin throwing/trapping in its generator code; plugin panics on unusual terrain data (e.g. out-of-range biome/block IDs); plugin built against a mismatched worldgen API version.","solutions":["Read the embedded {error} to find the failing plugin (generator_id) and fix or remove that plugin's generator","Update the worldgen plugin to the server's plugin API version and retest on a test world","Wrap the generator's phase logic in the plugin with error handling so it returns recoverable errors instead of trapping","Host-side: replace the panic with disabling the offending generator and logging, so the server keeps running"],"exampleFix":"// before\n            if let Err(error) = result {\n                panic!(\"Wasm chunk generation phase failed for generator {generator_id}: {error}\");\n            }\n// after\n            if let Err(error) = result {\n                log::error!(\"disabling generator {generator_id}: phase failed: {error}\");\n                return; // fall back to default generation for this chunk\n            }","handlingStrategy":"try-catch","validationCode":"// host-side guard before scheduling generation\nif !plugin_is_healthy(generator_id) {\n    log::warn!(\"generator {generator_id} failed health check; skipping\");\n    return default_generation(chunk);\n}","typeGuard":null,"tryCatchPattern":"match std::panic::catch_unwind(|| generator.generate_chunk(chunk)) {\n    Ok(result) => result,\n    Err(_) => {\n        log::error!(\"generator {generator_id} panicked; using default generation\");\n        default_generation(chunk)\n    }\n}","preventionTips":["Test worldgen plugins on a scratch world before deploying to production","Keep worldgen plugins updated to the server's API version","Wrap plugin phase code in error handling so errors are returned, not trapped","Monitor server logs for generator failures and disable repeat offenders"],"tags":["wasm","worldgen","panic","chunk-generation"],"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"}