Skip to content

stdio: a progress frame abandoned mid-flush is left partial on the wire (follow-up to #1548/#1549) #1557

Todo

Description

@joulook

Describe the bug

This regression was introduced by #1549, our pull request. Since #1549 the service loop drops the send future of a
progress notification once the peer cancels its request.
For AsyncRwTransport, send encodes the whole frame into its FramedWrite buffer and then flushes it. If the
output pipe is full, the future is dropped during that flush, and the rest of the frame stays in the buffer.

Nothing resumes that flush: receive() only flushes its own pending error reply, and close() drops the writer
without flushing. A later outgoing message would flush the tail first. If nothing else is sent before shutdown, the
peer reads a truncated JSON line and then EOF.

This breaks the Transport::send contract added in #1549: a dropped future must not leave a partial message. It was
flagged by the automated review on #1549 (on 9b2f62d, service.rs near the progress select).

To reproduce

Serve a tool over AsyncRwTransport with a 64-byte output pipe. The tool sends one progress notification longer
than 64 bytes and then waits for its cancellation.

  1. Call the tool with a progress token.
  2. Wait until the progress write is pending (the pipe is full).
  3. Send notifications/cancelled for the call.
  4. Close the input.
  5. Read the server's output to EOF.

On main (50fc08a) the output ends inside the progress frame, at exactly 64 bytes: {"jsonrpc":"2.0","method":"notifications/progress","params":{"me. This happens 3 times out of 3.

On 181cb98, before #1549, the same test passes: progress sends were never abandoned.

A byte-level model of the stdio write path (Daavar benchmarks/mcp-cancel, the frame cell) shows the same
truncated frame as a conformance violation on main over all interleavings of that model within the cell (assuming
the peer drains within the close bound; the cell's README states its limits).

Expected behavior

Every line the peer reads is a whole JSON message. A progress frame the transport has started writing reaches the
peer whole; one still waiting for the writer is dropped.

Found with. We are a research team at MPI-SWS building Daavar, a conformance checker for distributed protocol
implementations. This follow-up came from the automated review comment on #1549; we confirmed it natively (above) and with
a byte-level refinement of our model of rmcp's stdio write path, where each frame is written in two chunks that a full pipe
can hold apart. On that model the transport at main violates the specification program and the fixed transport conforms, over
all interleavings of the cell. This issue and the fix were prepared with AI assistance and reviewed by us.

Reproduce with Daavar (conformance test)

The cell ca,s0,frA: one tool call with a progress token, the client cancels it and shuts down, then reads the server's output
to EOF. The specification program writes both chunks of a frame together, so every frame the client reads is whole or absent.
implfo follows rmcp main 50fc08a; implff follows the fix. The join prints the words of the implementation the specification
does not produce as uncovered.

git clone --recurse-submodules https://github.com/joulook/daavar.git && cd daavar
git checkout 7fb70be && git submodule update --init --recursive
(cd traceforge && cargo build --release -p traceforge --bin conf-join)
cd benchmarks/mcp-cancel/rust && cargo build --release
B=target/release/tf_mcp_cancel; J=../../../traceforge/target/release/conf-join
$B export spec --out spec.jsonl  --model fifo -- spec,ca,s0,frA
$B export impl --out main.jsonl  --model fifo -- implfo,ca,s0,frA; $J --decide spec.jsonl main.jsonl   # violation: 1 uncovered of 3, Head(progress) then Eof
$B export impl --out fixed.jsonl --model fifo -- implff,ca,s0,frA; $J --decide spec.jsonl fixed.jsonl  # 0 uncovered

The cells frC (no cancel; the drain deadline drops the held write after EOF) and frE (a later request after the abandoned
one) are in the benchmark's README with their counts.

Activity

  1. added
    bug
    P1
    T-transport
    T-service
    ready for work
    on Dec 3, 2026
  2. github-actions commented on Dec 3, 2026

    @github-actions
    Contributor

    @connor4312 is on triage rotation this week and is the reviewer for this one.

    Codex labeled this bug / P1 (T-transport, T-service). Please confirm or correct those labels.

    Automated triage. Labels are a first pass and the assigned maintainer has the final say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1T-serviceT-transportbugready for work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions