Pumpkin-MC/Pumpkin · error · CompressionError

Error while working with LZ4 compression

Error message

Error while working with LZ4 compression: {0}

What it means

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.

Solutions

  1. Log the wrapped io::Error and inspect the chunk file for corruption; delete/regenerate the affected chunk file
  2. Verify free disk space and write permissions on the world save directory
  3. Ensure the same compression scheme is configured for read and write paths

Example fix

// before: unwrapping or propagating raw io error
let compressed = lz4_compress(&raw)?;
// after: map into the chunk error with context
let compressed = lz4_compress(&raw).map_err(CompressionError::LZ4Error)?;
Defensive patterns

Strategy: try-catch

Type guard

if let Err(ChunkError::Compression(CompressionError::LZ4Error(io))) = result { /* inspect io.kind() */ }

Try / catch

match load_chunk(key) {
    Err(ChunkError::Compression(CompressionError::LZ4Error(e))) => eprintln!("LZ4 chunk IO failed: {e}; regenerating chunk"),
    other => other?,
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/1724b3578f8a81b2. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-world/src/chunk/mod.rs:62

#[derive(Error, Debug)]
pub enum ChunkWritingError {
    #[error("Io error: {0}")]
    IoError(std::io::Error),
    #[error("Compression error {0}")]
    Compression(CompressionError),
    #[error("Chunk serializing error: {0}")]
    ChunkSerializingError(String),
}

#[derive(Error, Debug)]
pub enum CompressionError {
    #[error("Compression scheme not recognised")]
    UnknownCompression,
    #[error("Error while working with zlib compression: {0}")]
    ZlibError(std::io::Error),
    #[error("Error while working with Gzip compression: {0}")]
    GZipError(std::io::Error),
    #[error("Error while working with LZ4 compression: {0}")]
    LZ4Error(std::io::Error),
    #[error("Error while working with zstd compression: {0}")]
    ZstdError(std::io::Error),
}

// Clone here cause we want to clone a snapshot of the chunk so we don't block writing for too long
pub struct ChunkData {
    pub section: ChunkSections,
    /// See `https://minecraft.wiki/w/Heightmap` for more info
    pub heightmap: std::sync::Mutex<ChunkHeightmaps>,
    pub x: i32,
    pub z: i32,
    pub block_ticks: ChunkTickScheduler<&'static Block>,
    pub fluid_ticks: ChunkTickScheduler<&'static Fluid>,
    pub pending_block_entities: std::sync::Mutex<FxHashMap<BlockPos, NbtCompound>>,
    pub light_engine: std::sync::Mutex<ChunkLight>,
    pub light_populated: AtomicBool,
    pub status: ChunkStatus,

View on GitHub (pinned to 8d4639e25a)