mcp: clean up stream metadata after completion (#592)

Address longstanding TODOs to clean up stream metadata after streams are
complete:

- Interpret a missing stream as a complete stream.
- Remove the request->stream mapping when the request completes. Any
writes after that point will fail as there can be no recipient.

Tested using examples/client/loadtest, and updating
TestStreamableTransports to check in-band and out-of-band behavior.
This commit is contained in:
Robert Findley 2025-10-20 14:57:56 -04:00 • committed by GitHub
commit 8aee8d39bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,6 +34,7 @@ var (
timeout = flag.Duration("timeout", 1*time.Second, "request timeout")
qps = flag.Int("qps", 100, "tool calls per second, per worker")
verbose = flag.Bool("v", false, "if set, enable verbose logging")
cleanup = flag.Bool("cleanup", true, "whether to clean up sessions at the end of the test")
)
func main() {
@ -76,7 +77,9 @@ func main() {
if err != nil {
log.Fatal(err)
}
defer cs.Close()
if *cleanup {
defer cs.Close()
}
ticker := time.NewTicker(1 * time.Second / time.Duration(*qps))
defer ticker.Stop()