Repository navigation
Conversation
|
One edge case appears to leave the original silent-stdio hang intact for custom/wrapped transports.
This is especially easy to hit for instrumentation/filtering wrappers (the codebase already has precedent for wrapped transport/connection types). Could stdio/discover-timeout capability be preserved through a small optional interface/marker, or otherwise made wrapper-safe, instead of relying only on the concrete outer transport type? A regression can wrap the same silent AI assistance was used to inspect the patch; no acceptance/merge claim is implied. |
d8b43e6 to
c481cad
Compare
|
Thanks, good catch. I switched the check from the transport type to the connection it returns. The probe is now bounded whenever the connection is a newline-delimited stream connection ( A wrapper that also wraps the |
| return cs, nil | ||
| } | ||
|
|
||
| var streamDiscoverTimeout = 3 * time.Second // mutable for testing |
There was a problem hiding this comment.
i think this should be made configurable
There was a problem hiding this comment.
Done. I added ClientSessionOptions.DiscoverTimeout, next to ProtocolVersion:
- zero keeps the default (3s on stdio, IO and in-memory transports, unbounded elsewhere)
- a positive value applies on all transports, which also covers custom transports that wrap the
Connection - a negative value disables the bound
It's still capped at half of the remaining Connect deadline. Since this adds an exported field, let me know if you'd like a separate proposal issue for it.
On stdio transports, a handshake-era server may silently ignore
server/discover, which the stdio spec permits.Connectthen blocked until the caller's context expired and never reached theinitializefallback, which reused the same expired context.Connectnow bounds the discover probe at 3s, or half of the caller's remaining deadline if that is shorter, when the transport's connection is a newline-delimited stream connection. That coversCommandTransport,IOTransport,StdioTransportandInMemoryTransport, including throughLoggingTransportor a custom transport that returns the inner connection. On timeout it falls back toinitializeas for any other discover error. HTTP transports are unchanged.ClientSessionOptions.DiscoverTimeoutchanges the bound: a positive value applies it on all transports, and a negative value disables it.A modern stdio server that answers discover only after the probe times out still connects through
initialize, so it gets the 2025-11-25 protocol. Its late discover reply is dropped.Fixes #1332