Summary
Command Code crashes with "write EOF" uncaught exception when an MCP tool returns a very large response (~670K characters). The crash happens in the stream writing code when the payload exceeds the buffer capacity.
Expected Behavior
Command Code should handle large MCP responses gracefully by either truncating the response to fit the buffer, using proper chunked streaming, or returning a controlled error message instead of crashing.
Actual Behavior
Command Code throws an uncaught exception and terminates:
- Error: write EOF
- Stack: WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:87:19)
- Trace ID: c5f17b594a2313360360eafa56039939
Steps to reproduce the issue
Steps to reproduce:
- Add Engraphis MCP: cmd mcp add --scope user --env ENGRAPHIS_DB_PATH="C:\Users\your_user.engraphis\engraphis.db" engraphis -- engraphis mcp
- Call engraphis_execute_action with query "x query" in workspace "whatever-workspace", k=whatever-model-calls
- MCP returns a huge response (~670K characters) exceeding the token budget
- Command Code crashes immediately
Command Code Version
1.44.0
Operating System
Windows
Terminal/IDE
Orca
Shell
cmd.exe
Session file (optional)
Dropped as a json because you can't drop on jsonl
command-code-session-57ad15f5.json
Fix prompt (optional)
Fix prompt:
The crash occurs in the MCP response handling when a tool returns a payload larger than the Node.js stream buffer can handle (~670K chars in this case).
Where: MCP tool execution and response streaming code, likely in the tool call handler that writes results back to the agent.
-
Add a size check before writing MCP responses - if response exceeds a safe threshold (e.g., 1MB), either:
- Truncate with a warning message
- Stream in chunks using proper backpressure handling
-
Wrap the write operation in a try/catch to return a controlled error instead of crashing
-
Ensure the write stream is properly drained before closing
How to check:
- Reproduce by calling any MCP tool that returns a very large response (>500K chars)
- Verify Command Code doesn't crash and either:
- Returns the full response successfully, OR
- Returns a graceful error: "Response too large (X bytes). Use token_budget to limit response size."
- Check that normal-sized responses still work as before
Additional context
The crash happened while using Engraphis MCP for project context recall. The response was truncated at ~671K characters, suggesting the write stream failed when handling the large payload.
Summary
Command Code crashes with "write EOF" uncaught exception when an MCP tool returns a very large response (~670K characters). The crash happens in the stream writing code when the payload exceeds the buffer capacity.
Expected Behavior
Command Code should handle large MCP responses gracefully by either truncating the response to fit the buffer, using proper chunked streaming, or returning a controlled error message instead of crashing.
Actual Behavior
Command Code throws an uncaught exception and terminates:
- Error: write EOF
- Stack: WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:87:19)
- Trace ID: c5f17b594a2313360360eafa56039939
Steps to reproduce the issue
Steps to reproduce:
Command Code Version
1.44.0
Operating System
Windows
Terminal/IDE
Orca
Shell
cmd.exe
Session file (optional)
Dropped as a json because you can't drop on jsonl
command-code-session-57ad15f5.json
Fix prompt (optional)
Fix prompt:
The crash occurs in the MCP response handling when a tool returns a payload larger than the Node.js stream buffer can handle (~670K chars in this case).
Where: MCP tool execution and response streaming code, likely in the tool call handler that writes results back to the agent.
Add a size check before writing MCP responses - if response exceeds a safe threshold (e.g., 1MB), either:
- Truncate with a warning message
- Stream in chunks using proper backpressure handling
Wrap the write operation in a try/catch to return a controlled error instead of crashing
Ensure the write stream is properly drained before closing
How to check:
Additional context
The crash happened while using Engraphis MCP for project context recall. The response was truncated at ~671K characters, suggesting the write stream failed when handling the large payload.