{"record":{"id":"f57af55b7de3b45c","repo":"earendil-works/pi","slug":"frame-payload-exceeds-the-unsigned-32-bit-length-l","errorCode":null,"errorMessage":"Frame payload exceeds the unsigned 32-bit length limit","messagePattern":"Frame payload exceeds the unsigned 32-bit length limit","errorType":"exception","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"packages/protocol/src/framing.ts","lineNumber":30,"sourceCode":"export class FrameError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"FrameError\";\n\t}\n}\n\nfunction resolveMaxFrameLength(options: FrameDecoderOptions | undefined): number {\n\tconst value = options?.maxFrameLength ?? DEFAULT_MAX_FRAME_LENGTH;\n\tif (!Number.isSafeInteger(value) || value < 0 || value > MAX_UINT32) {\n\t\tthrow new RangeError(`maxFrameLength must be an integer between 0 and ${MAX_UINT32}`);\n\t}\n\treturn value;\n}\n\n/** Prefixes a payload with its unsigned 32-bit big-endian byte length. */\nexport function encodeFrame(payload: Uint8Array): Uint8Array {\n\tif (!(payload instanceof Uint8Array)) throw new TypeError(\"Frame payload must be a Uint8Array\");\n\tif (payload.byteLength > MAX_UINT32) throw new RangeError(\"Frame payload exceeds the unsigned 32-bit length limit\");\n\tconst frame = new Uint8Array(FRAME_HEADER_LENGTH + payload.byteLength);\n\tconst length = payload.byteLength;\n\tframe[0] = length >>> 24;\n\tframe[1] = length >>> 16;\n\tframe[2] = length >>> 8;\n\tframe[3] = length;\n\tframe.set(payload, FRAME_HEADER_LENGTH);\n\treturn frame;\n}\n\n/** Validates that bytes contain exactly one complete frame within the configured limit. */\nexport function assertCompleteFrame(frame: Uint8Array, options?: FrameDecoderOptions): void {\n\tif (!(frame instanceof Uint8Array)) throw new TypeError(\"Frame must be a Uint8Array\");\n\tif (frame.byteLength < FRAME_HEADER_LENGTH) throw new FrameError(\"Frame does not contain a complete length prefix\");\n\tconst length = frame[0]! * 0x1_000_000 + frame[1]! * 0x1_0000 + frame[2]! * 0x100 + frame[3]!;\n\tconst maxFrameLength = resolveMaxFrameLength(options);\n\tif (length > maxFrameLength) {\n\t\tthrow new FrameError(`Frame length ${length} exceeds configured limit of ${maxFrameLength}`);","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/protocol/src/framing.ts#L12-L48","documentation":"Error \"Frame payload exceeds the unsigned 32-bit length limit\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/protocol/src/framing.ts:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The payload exceeds the 32-bit length limit; split it into smaller frames."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}