Pumpkin-MC/Pumpkin · error · PacketEncodeError
Compression failed
Error message
Compression failed {0} What it means
`PacketEncodeError::CompressionFailed` is returned when the zlib/flate2 compressor fails while compressing an outgoing packet. The underlying compressor message is carried in the variant. This indicates the encoder could not produce a compressed frame.
Solutions
- Check server memory availability — compression failures often stem from allocation failures.
- Verify the configured compression level is in the valid 0-9 range.
- Retry encoding once; if it recurs, restart the encoder/compressor state.
- Report with the inner message if it persists, as it may indicate a flate2 backend issue.
Defensive patterns
Strategy: try-catch
Try / catch
match write_packet(&packet, version, &mut out) {
Ok(()) => {},
Err(PacketEncodeError::CompressionFailed(msg)) => {
log::error!("compression failed: {msg}; retrying uncompressed or dropping packet");
}
Err(e) => return Err(e.into()),
} Prevention
- Monitor server memory; compression failures correlate with allocation failures.
- Keep compression levels in the valid range.
- Avoid sharing compressor state across threads without synchronization.
When it happens
Trigger: Calling the packet encoder with compression enabled and the flate2 `write`/compress call returning an error — typically an allocation failure, an invalid configured compression level, or corrupted encoder state.
Common situations: Memory pressure in a long-running server; a bad compression level configured; reusing a compressor object across failed states.
Related errors
- Failed to verify username
- Invalid compression Level
- You are banned from Authentication servers
- Packet exceeds maximum length
- Writing packet failed
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/2509e81bacf04394.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-protocol/src/lib.rs:293
pub trait BClientPacket: Packet {
fn write_packet(&self, writer: impl Write) -> Result<(), Error>;
fn serialize_packet(&self) -> Result<Bytes, Error> {
crate::bedrock::packet_encoder::serialize_packet(self)
}
}
pub trait BServerPacket: Packet + Sized {
fn read(read: impl Read) -> Result<Self, Error>;
}
/// Errors that can occur during packet encoding.
#[derive(Error, Debug)]
pub enum PacketEncodeError {
#[error("Packet exceeds maximum length: {0}")]
TooLong(usize),
#[error("Compression failed {0}")]
CompressionFailed(String),
#[error("Writing packet failed: {0}")]
Message(String),
}
#[derive(Error, Debug)]
pub enum PacketDecodeError {
#[error("failed to decode packet ID")]
DecodeID,
#[error("packet exceeds maximum length")]
TooLong,
#[error("packet length is out of bounds")]
OutOfBounds,
#[error("malformed packet length VarInt: {0}")]
MalformedLength(String),
#[error("failed to decompress packet: {0}")]
FailedDecompression(String), // Updated to include error details
#[error("packet is uncompressed but greater than the threshold")]View on GitHub (pinned to 8d4639e25a)