{"record":{"id":"d0521e05a9e94ed2","repo":"earendil-works/pi","slug":"frame-chunk-must-be-a-uint8array","errorCode":null,"errorMessage":"Frame chunk must be a Uint8Array","messagePattern":"Frame chunk must be a Uint8Array","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/protocol/src/framing.ts","lineNumber":76,"sourceCode":"export class FrameDecoder {\n\tprivate readonly header = new Uint8Array(FRAME_HEADER_LENGTH);\n\tprivate headerLength = 0;\n\tprivate readonly maxFrameLength: number;\n\tprivate payloadBlocks: Uint8Array[] = [];\n\tprivate currentPayloadBlock: Uint8Array | undefined;\n\tprivate currentPayloadBlockLength = 0;\n\tprivate expectedPayloadLength: number | undefined;\n\tprivate payloadLength = 0;\n\tprivate state: DecoderState = \"open\";\n\n\tconstructor(options?: FrameDecoderOptions) {\n\t\tthis.maxFrameLength = resolveMaxFrameLength(options);\n\t}\n\n\tpush(chunk: Uint8Array): Uint8Array[] {\n\t\tif (this.state === \"ended\") throw new FrameError(\"Frame decoder has ended\");\n\t\tif (this.state === \"failed\") throw new FrameError(\"Frame decoder has failed\");\n\t\tif (!(chunk instanceof Uint8Array)) throw new TypeError(\"Frame chunk must be a Uint8Array\");\n\n\t\tconst frames: Uint8Array[] = [];\n\t\tlet chunkOffset = 0;\n\t\twhile (chunkOffset < chunk.byteLength) {\n\t\t\tif (this.expectedPayloadLength === undefined) {\n\t\t\t\tconst headerBytes = Math.min(FRAME_HEADER_LENGTH - this.headerLength, chunk.byteLength - chunkOffset);\n\t\t\t\tthis.header.set(chunk.subarray(chunkOffset, chunkOffset + headerBytes), this.headerLength);\n\t\t\t\tthis.headerLength += headerBytes;\n\t\t\t\tchunkOffset += headerBytes;\n\t\t\t\tif (this.headerLength < FRAME_HEADER_LENGTH) continue;\n\n\t\t\t\tconst frameLength =\n\t\t\t\t\tthis.header[0]! * 0x1_000_000 + this.header[1]! * 0x1_0000 + this.header[2]! * 0x100 + this.header[3]!;\n\t\t\t\tthis.headerLength = 0;\n\t\t\t\tif (frameLength > this.maxFrameLength) {\n\t\t\t\t\tthis.fail(`Frame length ${frameLength} exceeds configured limit of ${this.maxFrameLength}`);\n\t\t\t\t}\n\t\t\t\tif (frameLength === 0) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/protocol/src/framing.ts#L58-L94","documentation":"Error \"Frame chunk must be a Uint8Array\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/protocol/src/framing.ts:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Push chunks as Uint8Array; convert other types first."],"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"}