Pumpkin-MC/Pumpkin · error · CompressionError

Error while working with zstd compression

Error message

Error while working with zstd compression: {0}

What it means

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.

Solutions

  1. Inspect the wrapped io::Error; delete/regenerate the corrupted chunk file
  2. Check disk space and write permissions for the world directory
  3. Make sure the compression scheme matches on both write and read paths

Example fix

// before
let out = zstd::encode_all(&data[..], level)?;
// after
let out = zstd::encode_all(&data[..], level).map_err(CompressionError::ZstdError)?;
Defensive patterns

Strategy: try-catch

Type guard

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

Try / catch

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

Prevention

When it happens

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

Common situations: Corrupted region files, interrupted world saves, disk-full conditions, or region data written by a different compression setting.

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

Appendix: source

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

    #[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,
    pub blending_data: Option<crate::generation::blender::blending_data::BlendingData>,
    pub dirty: AtomicBool,

View on GitHub (pinned to 8d4639e25a)