{"record":{"id":"2509e81bacf04394","repo":"Pumpkin-MC/Pumpkin","slug":"compression-failed-0","errorCode":null,"errorMessage":"Compression failed {0}","messagePattern":"Compression failed (.+?)","errorType":"exception","errorClass":"PacketEncodeError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/lib.rs","lineNumber":293,"sourceCode":"\npub trait BClientPacket: Packet {\n    fn write_packet(&self, writer: impl Write) -> Result<(), Error>;\n\n    fn serialize_packet(&self) -> Result<Bytes, Error> {\n        crate::bedrock::packet_encoder::serialize_packet(self)\n    }\n}\n\npub trait BServerPacket: Packet + Sized {\n    fn read(read: impl Read) -> Result<Self, Error>;\n}\n\n/// Errors that can occur during packet encoding.\n#[derive(Error, Debug)]\npub enum PacketEncodeError {\n    #[error(\"Packet exceeds maximum length: {0}\")]\n    TooLong(usize),\n    #[error(\"Compression failed {0}\")]\n    CompressionFailed(String),\n    #[error(\"Writing packet failed: {0}\")]\n    Message(String),\n}\n\n#[derive(Error, Debug)]\npub enum PacketDecodeError {\n    #[error(\"failed to decode packet ID\")]\n    DecodeID,\n    #[error(\"packet exceeds maximum length\")]\n    TooLong,\n    #[error(\"packet length is out of bounds\")]\n    OutOfBounds,\n    #[error(\"malformed packet length VarInt: {0}\")]\n    MalformedLength(String),\n    #[error(\"failed to decompress packet: {0}\")]\n    FailedDecompression(String), // Updated to include error details\n    #[error(\"packet is uncompressed but greater than the threshold\")]","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/lib.rs#L275-L311","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Memory pressure in a long-running server; a bad compression level configured; reusing a compressor object across failed states.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match write_packet(&packet, version, &mut out) {\n    Ok(()) => {},\n    Err(PacketEncodeError::CompressionFailed(msg)) => {\n        log::error!(\"compression failed: {msg}; retrying uncompressed or dropping packet\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Monitor server memory; compression failures correlate with allocation failures.","Keep compression levels in the valid range.","Avoid sharing compressor state across threads without synchronization."],"tags":["protocol","compression","packet-encoding","zlib"],"backgroundTag":"compression-failed","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}