{"record":{"id":"df724b616faa8839","repo":"Pumpkin-MC/Pumpkin","slug":"packet-exceeds-maximum-length-0","errorCode":null,"errorMessage":"Packet exceeds maximum length: {0}","messagePattern":"Packet exceeds maximum length: (.+?)","errorType":"exception","errorClass":"PacketEncodeError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-protocol/src/lib.rs","lineNumber":291,"sourceCode":"    fn read(read: &mut &'a [u8], version: &JavaMinecraftVersion) -> Result<Self, ReadingError>;\n}\n\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}\")]","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-protocol/src/lib.rs#L273-L309","documentation":"`PacketEncodeError::TooLong` is returned when a serialized packet exceeds the protocol's maximum packet length (the largest length the length-prefix VarInt/frame allows). The payload size is carried in the variant so the caller can log it. Encoding is aborted before writing to the network.","triggerScenarios":"Encoding a packet whose serialized buffer (before or after compression) is larger than the maximum allowed frame size — e.g. a huge chunk update, a giant chat/NBT payload, or an uncompressed packet that should have been compressed.","commonSituations":"Sending enormous world data or NBT blobs in one packet; compression disabled so a payload that would fit compressed exceeds the raw limit; a plugin building an oversized payload.","solutions":["Enable/configure compression so large payloads fit under the frame limit.","Split the payload into multiple smaller packets (e.g. chunk sections separately).","Log the reported size and compare against the protocol's max packet length to see how far over the limit you are.","Trim the packet contents (e.g. reduce entity metadata or NBT size)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const MAX_PACKET_LEN: usize = 2_097_151; // 3-byte VarInt max\nif encoded.len() > MAX_PACKET_LEN {\n    return Err(PacketEncodeError::TooLong(encoded.len()));\n}","typeGuard":null,"tryCatchPattern":"match write_packet(&packet, version, &mut out) {\n    Ok(()) => {},\n    Err(PacketEncodeError::TooLong(n)) => {\n        log::error!(\"packet too large ({n} bytes); splitting payload\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Enable compression for payloads near the frame limit.","Chunk large world/NBT data into multiple packets.","Assert packet sizes in tests for the largest packets your server sends."],"tags":["protocol","packet-encoding","size-limit","network"],"backgroundTag":"payload-too-large","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"}