earendil-works/pi · error · FrameError
Truncated frame at end of stream
Error message
Truncated frame at end of stream
What it means
At clean end-of-stream the decoder still holds a partial header or an incomplete payload, i.e. the stream was cut off mid-frame. fail() marks the decoder failed and reports this; the peer disconnected or data was truncated in transit.
Solutions
- The stream ended mid-frame; ensure the writer flushed complete frames before closing.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/protocol/src/framing.ts:163 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/7d8786cab88865e5.
Report an issue: GitHub.
Appendix: source
Thrown at packages/protocol/src/framing.ts:163
end(): void {
if (this.state === "ended") throw new FrameError("Frame decoder has ended");
if (this.state === "failed") throw new FrameError("Frame decoder has failed");
if (this.headerLength !== 0 || this.expectedPayloadLength !== undefined) {
this.fail("Truncated frame at end of stream");
}
this.state = "ended";
}
private fail(message: string): never {
this.state = "failed";
this.headerLength = 0;
this.payloadBlocks = [];
this.currentPayloadBlock = undefined;
this.currentPayloadBlockLength = 0;
this.expectedPayloadLength = undefined;
this.payloadLength = 0;
throw new FrameError(message);
}
}
View on GitHub (pinned to 4af9d21d3b)