earendil-works/pi · error · FrameError
Frame decoder has ended
Error message
Frame decoder has ended
What it means
Error "Frame decoder has ended" thrown in earendil-works/pi.
Source
Thrown at packages/protocol/src/framing.ts:74
/** Incrementally splits arbitrary byte chunks into length-prefixed payloads. */
export class FrameDecoder {
private readonly header = new Uint8Array(FRAME_HEADER_LENGTH);
private headerLength = 0;
private readonly maxFrameLength: number;
private payloadBlocks: Uint8Array[] = [];
private currentPayloadBlock: Uint8Array | undefined;
private currentPayloadBlockLength = 0;
private expectedPayloadLength: number | undefined;
private payloadLength = 0;
private state: DecoderState = "open";
constructor(options?: FrameDecoderOptions) {
this.maxFrameLength = resolveMaxFrameLength(options);
}
push(chunk: Uint8Array): Uint8Array[] {
if (this.state === "ended") throw new FrameError("Frame decoder has ended");
if (this.state === "failed") throw new FrameError("Frame decoder has failed");
if (!(chunk instanceof Uint8Array)) throw new TypeError("Frame chunk must be a Uint8Array");
const frames: Uint8Array[] = [];
let chunkOffset = 0;
while (chunkOffset < chunk.byteLength) {
if (this.expectedPayloadLength === undefined) {
const headerBytes = Math.min(FRAME_HEADER_LENGTH - this.headerLength, chunk.byteLength - chunkOffset);
this.header.set(chunk.subarray(chunkOffset, chunkOffset + headerBytes), this.headerLength);
this.headerLength += headerBytes;
chunkOffset += headerBytes;
if (this.headerLength < FRAME_HEADER_LENGTH) continue;
const frameLength =
this.header[0]! * 0x1_000_000 + this.header[1]! * 0x1_0000 + this.header[2]! * 0x100 + this.header[3]!;
this.headerLength = 0;
if (frameLength > this.maxFrameLength) {
this.fail(`Frame length ${frameLength} exceeds configured limit of ${this.maxFrameLength}`);View on GitHub (pinned to 4af9d21d3b)
Solutions
- The decoder was ended; create a new decoder or do not push chunks after end().
When it happens
Trigger: Thrown at packages/protocol/src/framing.ts:74 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/ebccf38f7f855cee.
Report an issue: GitHub.