can1357/oh-my-pi · error · ToolError
Invalid cmux socket response: missing ok flag
Error message
Invalid cmux socket response: missing ok flag
What it means
A parsed object reply that contains neither ok === true nor ok === false has no verdict flag, so #parseResponse throws this ToolError. It is the last-resort envelope validation: the peer produced a JSON object but not a cmux response object.
Source
Thrown at packages/coding-agent/src/tools/browser/cmux/socket-client.ts:403
throw new ToolError(line);
}
let payload: unknown;
try {
payload = JSON.parse(line);
} catch (err) {
throw new ToolError(`Invalid cmux socket JSON response: ${err instanceof Error ? err.message : String(err)}`);
}
if (!payload || typeof payload !== "object") {
throw new ToolError("Invalid cmux socket response: expected object");
}
const response = payload as { ok?: unknown; result?: unknown; error?: CmuxErrorPayload };
if (response.ok === true) {
return (response.result ?? {}) as Record<string, unknown>;
}
if (response.ok === false) {
throw new ToolError(formatCmuxError(response.error));
}
throw new ToolError("Invalid cmux socket response: missing ok flag");
}
#handleSocketFailure(err: Error): void {
if (this.#disposed) return;
this.#connected = false;
this.#connectPromise = null;
this.#rejectAll(new ToolError(`cmux socket error: ${err.message}`));
this.#socket?.destroy();
this.#socket = null;
}
#handleSocketClose(): void {
const hadPendingRead = this.#lineWaiters.length > 0;
this.#connected = false;
this.#connectPromise = null;
this.#socket = null;
if (!this.#disposed && hadPendingRead) {
this.#rejectAll(new ToolError("cmux socket closed"));View on GitHub (pinned to 9690622007)
Solutions
- Align client and daemon versions so the {ok,...} envelope contract holds on both ends
- Verify the socketPath targets the cmux control socket, not an event/notification stream
- Capture the offending raw line in daemon logs and fix or report the envelope regression
Defensive patterns
Strategy: type-guard
Type guard
function hasOkFlag(v: unknown): v is { ok: boolean } {
return typeof v === "object" && v !== null && "ok" in v && typeof (v as { ok: unknown }).ok === "boolean";
} Try / catch
try {
return await client.request(method, params);
} catch (err) {
if (err instanceof ToolError && err.message === "Invalid cmux socket response: missing ok flag") {
// envelope/protocol mismatch: align versions or check you're on the control socket
}
throw err;
} Prevention
- Keep client and daemon on the same protocol version — envelopes without ok come from version skew
- Ensure the socketPath is the request/response control socket, not an event stream
- Log raw lines during integration testing to catch envelope regressions early
When it happens
Trigger: Daemon (or another JSON service on the socket) returns objects like {"jsonrpc":"2.0","id":...} or event/notification objects lacking ok; protocol skew where newer daemons emit a different envelope for some methods.
Common situations: Mixing client and daemon versions; connecting to a different JSON-over-line service that happens to emit objects; daemon bug emitting notification frames interleaved into request replies.
Related errors
- Invalid cmux socket response: expected object
- Replacement text is not valid UTF-8: {err}
- Missing or invalid field "${field}" in catalog: ${filePath}
- Marketplace catalog at ${filePath} must be a JSON object
- rpc frame must be an object
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/8aa926099946c256.
Report an issue: GitHub.