fix(mcp): a close doesn't wait on a client's open event stream

A standalone event stream (the GET an MCP client keeps open) is no answer on
its way out and ends only with its session, which a close ends after it has
waited for the answers: counting it as an answer made every close sit out the
whole grace (10 s) whenever an assistant was connected, and a bridge asking
meanwhile could stall for its own 60 s. Only POSTs are counted, as the
server's own close counts them. A hand demonstration found it; the new test
(an rmcp client with its stream open, the close answered within 5 s) fails
without the fix (12 s).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 09:50:06 -07:00
1 parent 89403a7159
commit 8056e3bbc8
3 files changed
+55 -2

No files matched your search

+4 -2
View File
@@ -2191,8 +2191,10 @@ async fn mcp(
}
}
// The answer may still be on its way: it counts, for the server's close
// and for this book's, until its body ends.
let answering = _inside.answering();
// and for this book's, until its body ends. A standalone event stream
// (a GET) is no answer, and ends only with its session, after the close
// has waited for the answers.
let answering = (method != axum::http::Method::GET).then(|| _inside.answering());
response.map(|body| {
use http_body_util::BodyExt;
axum::body::Body::new(body.map_frame(move |frame| {