Pumpkin-MC/Pumpkin · error · ChunkSerializingError

Error serializing chunk

Error message

Error serializing chunk: {0}

What it means

Variant `ErrorSerializingChunk` of `ChunkSerializingError` in pumpkin-world. It wraps a `pumpkin_nbt::Error` raised while writing a `ChunkData` into NBT for persistence. The library throws it when converting chunk sections/palettes/block entities into the NBT representation fails during save.

Solutions

  1. Check the wrapped pumpkin_nbt::Error for the failing write operation
  2. Verify disk space and write permissions on the world save path
  3. If reproducible, capture the chunk state and file a bug — valid chunk data should always serialize
Defensive patterns

Strategy: try-catch

Type guard

matches!(err, ChunkSerializingError::ErrorSerializingChunk(_))

Try / catch

match save_chunk(&chunk) {
    Err(ChunkSerializingError::ErrorSerializingChunk(e)) => { error!("chunk save failed: {e}"); /* keep chunk in memory for retry */ }
    Ok(()) => {},
}

Prevention

When it happens

Trigger: Saving a chunk when NBT writing fails — e.g. invalid tag values, oversized data, or I/O-backed NBT writer errors.

Common situations: Disk-full or read-only world directory during autosave, in-memory chunk data violating NBT invariants after a bug or memory corruption.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


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

Appendix: source

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

            .rev()
            .find(|(_, sub)| !sub.has_only_air())
            .map_or(0, |(idx, _)| idx)
    }
}

#[derive(Error, Debug)]
pub enum ChunkParsingError {
    #[error("Failed reading chunk status {0}")]
    FailedReadStatus(pumpkin_nbt::Error),
    #[error("The chunk isn't generated yet")]
    ChunkNotGenerated,
    #[error("Error deserializing chunk: {0}")]
    ErrorDeserializingChunk(String),
}

#[derive(Error, Debug)]
pub enum ChunkSerializingError {
    #[error("Error serializing chunk: {0}")]
    ErrorSerializingChunk(pumpkin_nbt::Error),
}

#[cfg(test)]
mod tests {
    use super::ChunkSections;
    use crate::chunk::palette::BlockPalette;
    use pumpkin_data::{Block, block_properties::has_random_ticks};

    #[test]
    fn random_tick_cache_initializes_from_palette_contents() {
        let mut sections = vec![BlockPalette::default(), BlockPalette::default()];
        sections[1].set(0, 0, 0, Block::LAVA.default_state.id);

        let (cache, _mask) = ChunkSections::build_random_tick_sections_cache(&sections);
        let cache = cache.unwrap();
        assert!(!cache[0].is_randomly_ticking());
        assert!(cache[1].random_ticking_fluid_count > 0);

View on GitHub (pinned to 8d4639e25a)