{"record":{"id":"4deec07f8b593578","repo":"Hmbown/CodeWhale","slug":"failed-to-read-bounded-stdio-json-rpc-frame","errorCode":null,"errorMessage":"failed to read bounded stdio JSON-RPC frame: {}","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/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/mcp/src/lib.rs#L888-L924","documentation":"The stdio transport failed while reading a JSON-RPC frame from the child process's stdout under the bounded read (size limit). The frame was invalid (I/O or format error), an error response was sent to the caller, and this error is raised.","triggerScenarios":"Child process writes a line exceeding the bounded frame size limit; stdout pipe I/O error; child crashes mid-write producing a truncated/partial line; child emits binary garbage instead of newline-delimited JSON-RPC.","commonSituations":"MCP server binary printing large debug output or huge payloads; wrong binary/path so a non-MCP program writes to stdout; resource limits causing pipe failures.","solutions":["Inspect the wrapped source error ({err}) to distinguish size-limit vs I/O failure","Check the child's stdout for oversized or non-JSON-RPC output","Verify the configured server command actually speaks newline-delimited JSON-RPC MCP"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match manager.call_tool(...) { Err(e) if e.to_string().starts_with(\"failed to read bounded stdio JSON-RPC frame\") => /* restart child / check stdout */, other => other }","preventionTips":["Keep child stdout exclusively for JSON-RPC frames (log to stderr)","Enforce payload size limits in child responses","Validate the server command produces MCP protocol output"],"tags":["mcp","stdio","json-rpc","child-process"],"backgroundTag":"invalid-json-response","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}