Pumpkin-MC/Pumpkin · error · CompressionError

Error while working with zlib compression

Error message

Error while working with zlib compression: {0}

What it means

CompressionError variant from chunk (de)compression: the underlying zlib inflate/deflate call returned an io error while processing the chunk payload. The offending input is the zlib-compressed chunk byte stream from the region file — corrupted data, truncation, or a mismatched compression id will surface here wrapped in the io error.

Solutions

  1. Retry the chunk write; check disk state if persistent
  2. Validate the zlib stream before use
  3. Log the underlying io error

Example fix

// before
let raw = zlib_decode(payload).unwrap();
// after
let raw = zlib_decode(payload)
    .map_err(|e| { log::error!("zlib failure on chunk data: {e}"); e })?;
Defensive patterns

Strategy: try-catch

Type guard

fn is_zlib_failure(e: &CompressionError) -> Option<&std::io::Error> {
    if let CompressionError::ZlibError(e) = e { Some(e) } else { None }
}

Try / catch

match decompress_chunk(payload, Scheme::Zlib) {
    Err(CompressionError::ZlibError(e)) => { log::error!("zlib: {e}"); restore_from_backup() }
    other => other?,
}

Prevention

When it happens

Trigger: Decompressing a truncated or corrupt zlib payload from a region file, or a compressor failure while encoding chunk data during save.

Common situations: Region files cut short by crashes or partial transfers, bit-flip disk corruption, out-of-memory during large chunk compression.

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/a1c557b56d5a374d. Report an issue: GitHub.

Appendix: source

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

    #[error("Failed to parse chunk from bytes: {0}")]
    ParsingError(ChunkParsingError),
}

#[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>,

View on GitHub (pinned to 8d4639e25a)