{"record":{"id":"a2f4b88031afd168","repo":"Pumpkin-MC/Pumpkin","slug":"error-while-working-with-zstd-compression-0","errorCode":null,"errorMessage":"Error while working with zstd compression: {0}","messagePattern":"Error while working with zstd compression: (.+?)","errorType":"error_code","errorClass":"CompressionError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-world/src/chunk/mod.rs","lineNumber":64,"sourceCode":"    #[error(\"Io error: {0}\")]\n    IoError(std::io::Error),\n    #[error(\"Compression error {0}\")]\n    Compression(CompressionError),\n    #[error(\"Chunk serializing error: {0}\")]\n    ChunkSerializingError(String),\n}\n\n#[derive(Error, Debug)]\npub enum CompressionError {\n    #[error(\"Compression scheme not recognised\")]\n    UnknownCompression,\n    #[error(\"Error while working with zlib compression: {0}\")]\n    ZlibError(std::io::Error),\n    #[error(\"Error while working with Gzip compression: {0}\")]\n    GZipError(std::io::Error),\n    #[error(\"Error while working with LZ4 compression: {0}\")]\n    LZ4Error(std::io::Error),\n    #[error(\"Error while working with zstd compression: {0}\")]\n    ZstdError(std::io::Error),\n}\n\n// Clone here cause we want to clone a snapshot of the chunk so we don't block writing for too long\npub struct ChunkData {\n    pub section: ChunkSections,\n    /// See `https://minecraft.wiki/w/Heightmap` for more info\n    pub heightmap: std::sync::Mutex<ChunkHeightmaps>,\n    pub x: i32,\n    pub z: i32,\n    pub block_ticks: ChunkTickScheduler<&'static Block>,\n    pub fluid_ticks: ChunkTickScheduler<&'static Fluid>,\n    pub pending_block_entities: std::sync::Mutex<FxHashMap<BlockPos, NbtCompound>>,\n    pub light_engine: std::sync::Mutex<ChunkLight>,\n    pub light_populated: AtomicBool,\n    pub status: ChunkStatus,\n    pub blending_data: Option<crate::generation::blender::blending_data::BlendingData>,\n    pub dirty: AtomicBool,","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-world/src/chunk/mod.rs#L46-L82","documentation":"Variant `ZstdError` of the chunk compression error enum in pumpkin-world. It wraps an `std::io::Error` produced while compressing or decompressing chunk data with zstd. The library throws it when the zstd codec fails during chunk save/load.","triggerScenarios":"Saving or loading a chunk that selects zstd compression, when the zstd encoder/decoder returns an I/O error (corrupt frame, truncated input, write failure).","commonSituations":"Corrupted region files, interrupted world saves, disk-full conditions, or region data written by a different compression setting.","solutions":["Inspect the wrapped io::Error; delete/regenerate the corrupted chunk file","Check disk space and write permissions for the world directory","Make sure the compression scheme matches on both write and read paths"],"exampleFix":"// before\nlet out = zstd::encode_all(&data[..], level)?;\n// after\nlet out = zstd::encode_all(&data[..], level).map_err(CompressionError::ZstdError)?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"if let Err(ChunkError::Compression(CompressionError::ZstdError(io))) = result { /* inspect io.kind() */ }","tryCatchPattern":"match load_chunk(key) {\n    Err(ChunkError::Compression(CompressionError::ZstdError(e))) => eprintln!(\"zstd chunk IO failed: {e}; regenerating chunk\"),\n    other => other?,\n}","preventionTips":["Monitor disk space where region files are written","Back up world files before changing compression settings","Never edit region files with tools that do not support zstd"],"tags":["io","compression","zstd","chunks"],"backgroundTag":"file-read-failed","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}