{"record":{"id":"1724b3578f8a81b2","repo":"Pumpkin-MC/Pumpkin","slug":"error-while-working-with-lz4-compression-0","errorCode":null,"errorMessage":"Error while working with LZ4 compression: {0}","messagePattern":"Error while working with LZ4 compression: (.+?)","errorType":"error_code","errorClass":"CompressionError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-world/src/chunk/mod.rs","lineNumber":62,"sourceCode":"#[derive(Error, Debug)]\npub enum ChunkWritingError {\n    #[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,","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-world/src/chunk/mod.rs#L44-L80","documentation":"Variant `LZ4Error` of the chunk compression error enum in pumpkin-world. It wraps an `std::io::Error` raised while reading or writing a chunk that uses LZ4 compression. The library throws it when the LZ4 codec fails during chunk serialization/deserialization in the region/chunk save path.","triggerScenarios":"Saving or loading a chunk whose compression enum selects LZ4, when the underlying LZ4 encoder/decoder returns an I/O error (corrupt compressed bytes, truncated stream, or writer failure).","commonSituations":"Corrupted or partially written chunk files on disk, disk-full during chunk save, mismatched compression scheme between what wrote the region file and what reads it.","solutions":["Log the wrapped io::Error and inspect the chunk file for corruption; delete/regenerate the affected chunk file","Verify free disk space and write permissions on the world save directory","Ensure the same compression scheme is configured for read and write paths"],"exampleFix":"// before: unwrapping or propagating raw io error\nlet compressed = lz4_compress(&raw)?;\n// after: map into the chunk error with context\nlet compressed = lz4_compress(&raw).map_err(CompressionError::LZ4Error)?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"if let Err(ChunkError::Compression(CompressionError::LZ4Error(io))) = result { /* inspect io.kind() */ }","tryCatchPattern":"match load_chunk(key) {\n    Err(ChunkError::Compression(CompressionError::LZ4Error(e))) => eprintln!(\"LZ4 chunk IO failed: {e}; regenerating chunk\"),\n    other => other?,\n}","preventionTips":["Keep adequate disk space on the world save volume","Avoid killing the server mid-chunk-save; use graceful shutdown","Keep the compression scheme consistent across all write/read code paths"],"tags":["io","compression","lz4","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"}