can1357/oh-my-pi · error
RPC chunk exceeded the transport limit
Error message
RPC chunk exceeded the transport limit
What it means
encodeChunkedRpcFrames splits an oversized logical frame into protocol-v2 chunk lines, each of which must individually fit within MAX_RPC_FRAME_BYTES (1 MiB). This error is thrown when a single serialized chunk line exceeds that transport ceiling, which should be impossible from the encoder's own 256 KiB payload slices and indicates corrupted internal constants or tampered serialization. It is an internal-invariant guard, not a user-input validation.
Source
Thrown at packages/coding-agent/src/modes/rpc/rpc-frame.ts:114
yield `${JSON.stringify(overflowFrame(frame))}\n`;
return;
}
const bytes = Buffer.from(json, "utf8");
const count = Math.ceil(byteLength / RPC_CHUNK_PAYLOAD_BYTES);
for (let index = 0; index < count; index++) {
const chunk: RpcChunkFrame = {
type: "rpc_chunk",
chunkId,
index,
count,
byteLength,
data: bytes
.subarray(index * RPC_CHUNK_PAYLOAD_BYTES, (index + 1) * RPC_CHUNK_PAYLOAD_BYTES)
.toString("base64"),
};
const line = `${JSON.stringify(chunk)}\n`;
if (serializedFrameBytes(line.slice(0, -1)) > MAX_RPC_FRAME_BYTES)
throw new Error("RPC chunk exceeded the transport limit");
yield line;
}
}
function isRpcChunkFrame(value: unknown): value is RpcChunkFrame {
return isRecord(value) && value.type === "rpc_chunk";
}
function decodeBase64(data: unknown): Buffer {
if (
typeof data !== "string" ||
data.length === 0 ||
!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data)
)
throw new Error("invalid rpc chunk data");
const bytes = Buffer.from(data, "base64");
if (bytes.toString("base64") !== data) throw new Error("invalid rpc chunk data");
return bytes;View on GitHub (pinned to 9690622007)
Solutions
- Keep RPC_CHUNK_PAYLOAD_BYTES comfortably below MAX_RPC_FRAME_BYTES (256 KiB payload → ~350 KiB base64 line) and do not override either constant.
- Ensure chunkId stays short (≤128 chars) so JSON.stringify(chunk) metadata cannot inflate the line.
- If you control the sender, reduce the logical frame via compactTerminalFrame/shrink paths before chunking.
Example fix
// before: custom constants in a fork const RPC_CHUNK_PAYLOAD_BYTES = 900 * 1024; // near the 1MiB line limit // after const RPC_CHUNK_PAYLOAD_BYTES = 256 * 1024; // safely under MAX_RPC_FRAME_BYTES
Defensive patterns
Strategy: try-catch
Validate before calling
import { MAX_RPC_FRAME_BYTES } from "./rpc-frame";
// chunk lines from a 256KiB payload slice cannot exceed this unless constants drifted
if (Buffer.byteLength(JSON.stringify(chunk), "utf8") + 1 > MAX_RPC_FRAME_BYTES) {
throw new Error("chunk size configuration inconsistent with transport limit");
} Try / catch
try {
for (const line of encoder.encodeFrames(frame)) process.stdout.write(line);
} catch (err) {
if (err instanceof Error && err.message === "RPC chunk exceeded the transport limit") {
logger.error("RPC chunking constants are inconsistent; frame dropped", { frameType: frame.type });
} else throw err;
} Prevention
- Never fork or override MAX_RPC_FRAME_BYTES / RPC_CHUNK_PAYLOAD_BYTES independently.
- Keep chunkId short (≤128 chars).
- Rely on compactTerminalFrame/shrink paths to reduce frames before chunking.
When it happens
Trigger: Calling RpcFrameEncoder.encodeFrames (via encode) under protocol v2 with a frame larger than MAX_RPC_FRAME_BYTES, where a generated 256 KiB base64 chunk line plus JSON metadata exceeds MAX_RPC_FRAME_BYTES — only possible if RPC_CHUNK_PAYLOAD_BYTES/MAX_RPC_FRAME_BYTES constants are inconsistent or JSON escaping of chunkId blows up the line.
Common situations: Almost never hit in practice; a fork or patch that changed chunk payload size without re-checking the frame limit, or a downstream build that overrode the constants.
Related errors
- rpc chunk payload exceeds the transport limit
- Replacement text is not valid UTF-8: {err}
- invalid glob `{pattern}`: {error}
- RPC chunk received before protocol negotiation
- RPC protocol v2 negotiation failed
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/2828425a73fe67ad.
Report an issue: GitHub.