{"record":{"id":"c72141e0177367e3","repo":"Hmbown/CodeWhale","slug":"failed-to-read-bounded-stdio-json-rpc-frame-err","errorCode":null,"errorMessage":"failed to read bounded stdio JSON-RPC frame: {err}","messagePattern":"failed to read bounded stdio JSON-RPC frame: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mcp/src/lib.rs","lineNumber":906,"sourceCode":"    let mut stdout = io::stdout();\n    let mut stderr = io::stderr();\n    let mut state = build_stdio_state(initial_definitions);\n    let mut input = stdin.lock();\n\n    loop {\n        let line =\n            match stdio_client::read_bounded_line(&mut input, stdio_client::MAX_JSONRPC_LINE_BYTES)\n            {\n                Ok(Some(line)) => line,\n                Ok(None) => break,\n                Err(err) => {\n                    let response = jsonrpc_error(\n                        None,\n                        JsonRpcError::parse_error(format!(\"invalid JSON-RPC frame: {err}\")),\n                    );\n                    writeln!(stdout, \"{response}\")?;\n                    stdout.flush()?;\n                    bail!(\"failed to read bounded stdio JSON-RPC frame: {err}\");\n                }\n            };\n        if line.trim().is_empty() {\n            continue;\n        }\n\n        let value: Value = match serde_json::from_str(&line) {\n            Ok(value) => value,\n            Err(err) => {\n                let msg = jsonrpc_error(\n                    None,\n                    JsonRpcError::parse_error(format!(\"invalid json: {err}\")),\n                );\n                writeln!(stdout, \"{msg}\")?;\n                stdout.flush()?;\n                continue;\n            }\n        };","sourceCodeStart":888,"sourceCodeEnd":924,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/mcp/src/lib.rs#L888-L924","documentation":"The stdio JSON-RPC transport reads length/size-bounded frames (lines) from the child process. When reading a frame fails (IO error, oversized/bounded-frame violation), the transport emits a JSON-RPC parse error response and then bails with this message naming the underlying error. It signals the stdio channel with the MCP child is broken or misbehaving.","triggerScenarios":"A read of a bounded stdio JSON-RPC frame from the child process returns an error (err), e.g. the frame exceeds the size bound, the pipe closed mid-frame, or an OS-level read failure.","commonSituations":"Child process crashed or exited while a request was in flight; child emitted a frame larger than the configured bound (huge tool output); broken pipe after the child was killed by OOM or signal; non-JSON-RPC output corrupting the framing.","solutions":["Check the child process is alive and healthy (exit status, stderr logs); restart the MCP server process and retry.","Reduce frame size (limit tool output / request size) or raise the configured read bound if it is genuinely too small.","Inspect the embedded {err} for the root cause: pipe closed vs size limit vs IO error, and fix accordingly (fix child crash, adjust limit, check permissions)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"fn child_alive(child: &std::process::Child) -> bool {\n    matches!(child.try_wait(), Ok(None))\n}\n// verify child liveness (and that a frame size limit is configured generously) before issuing requests","typeGuard":null,"tryCatchPattern":"match transport.call(request) {\n    Err(e) if e.to_string().contains(\"failed to read bounded stdio JSON-RPC frame\") => {\n        tracing::error!(\"stdio transport failed: {e}; restarting server\");\n        restart_child()?; // then retry once\n    }\n    other => other,\n}","preventionTips":["Monitor child stderr and exit status; restart crashed servers proactively.","Cap tool output size so frames stay under the read bound.","Detect broken pipe / child exit early and fail the pending request fast instead of waiting."],"tags":["mcp","stdio","json-rpc","io"],"backgroundTag":"json-parse-error","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}