You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
StdioTransport.send() still interleaves concurrent sends under EAGAIN backpressure — #252 was closed without a merged fix #263
StdioTransport.send() can splice the bytes of one JSON-RPC frame into the
middle of another when two sends run concurrently and the first hits stdout
backpressure. This corrupts the newline-delimited framing for any client
reading the stream.
This is the same defect reported in #252 (2026-07-02). That issue was closed
by its reporter the next day with no linked commit or PR, and the code on main today is unchanged — the bug is still present. Filing fresh with an
independent, in-the-wild reproduction.
Root cause
StdioTransport is an actor, but send(_:) contains an await inside its
write loop — the EAGAIN backpressure sleep:
}catchleterrorwhereMCPError.isResourceTemporarilyUnavailable(error) {
tryawaitTask.sleep(for:.milliseconds(10)) // ← actor reentrancy point
continue}
Actor isolation guarantees mutual exclusion only between suspension
points. While one send is suspended in that sleep mid-frame, a second send enters the actor and writes its complete frame into the middle of the
first one.
Observed in the wild
Version 0.12.1, macOS 15 (Darwin 25.5), a stdio MCP server whose initialize result carries a ~1.9 KB instructions string. A pipelining
client sent initialize + a tools/call back-to-back; the captured stdout
shows the tool response spliced mid-word into the initialize result:
...has not made any bucket visi{"id":2,"jsonrpc":"2.0","result":{...}}
ble to agents yet...
Both frames are unparseable to a line-delimited JSON reader at that point.
Any client that issues parallel tool calls (several do) can trigger this
whenever a response exceeds what the pipe accepts in one write — no
misbehaving client required.
Reproduction sketch
Same shape as #252's: create the transport over a pipe the reader drains
slowly, start a send large enough to hit EAGAIN (hundreds of KB, or a small
pipe), and issue a second small send while the first is suspended. The small
frame lands inside the large one.
Suggested fix
Serialize sends so one completes before the next begins — either drop to a
blocking write for the remainder of a frame, or chain sends FIFO. We shipped
the FIFO as a wrapper in our server and it eliminates the corruption:
The same pattern inlined into StdioTransport.send (chain before the write
loop) would fix it at the source. Happy to turn this into a PR if that's
welcome.
Fixed on rel/1.0.0 (#372) across #388, #407, and #413: concurrent StdioTransport.send calls are now serialized in FIFO call order so frames never interleave under backpressure, and a send cancelled after writing part of its frame finishes the frame rather than leaving torn JSON on the pipe. Closing as resolved in 1.0.0.
Activity
Merge pr/266: fix stdio frame interleaving under backpressure (upstream
jeanmatthieu commentedon Dec 5, 2026
Fixed on
rel/1.0.0(#372) across #388, #407, and #413: concurrentStdioTransport.sendcalls are now serialized in FIFO call order so frames never interleave under backpressure, and a send cancelled after writing part of its frame finishes the frame rather than leaving torn JSON on the pipe. Closing as resolved in 1.0.0.