mcp: re-enable race test after fixing data races (#851)

1. (non-test) Don't queue notifications if there are no connected
sessions.
2. Change `reconnectInitialDelay` to be atomic, as it is modified in
tests.
3. Protect map access with mutex in `TestServerTransportCleanup`.
This commit is contained in:
Maciej Kisiel 2026-03-23 08:35:27 +01:00 • committed by GitHub
commit 755b9ed4df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -446,10 +446,10 @@ func TestStreamableClientResumption_Cancelled(t *testing.T) {
//
// TODO(#680): experiment with instead using synctest.
const tick = 10 * time.Millisecond
defer func(delay time.Duration) {
reconnectInitialDelay = delay
}(reconnectInitialDelay)
reconnectInitialDelay = 2 * tick
defer func(delay int64) {
reconnectInitialDelay.Store(delay)
}(reconnectInitialDelay.Load())
reconnectInitialDelay.Store(int64(2 * tick))
// The setup: terminate a request stream and make the resumed request hang
// indefinitely. CallTool should still exit when its context is canceled.
@ -702,10 +702,10 @@ func TestStreamableClientTransientErrors(t *testing.T) {
func TestStreamableClientRetryWithoutProgress(t *testing.T) {
// Speed up reconnection delays for testing.
const tick = 10 * time.Millisecond
defer func(delay time.Duration) {
reconnectInitialDelay = delay
}(reconnectInitialDelay)
reconnectInitialDelay = tick
defer func(delay int64) {
reconnectInitialDelay.Store(delay)
}(reconnectInitialDelay.Load())
reconnectInitialDelay.Store(int64(tick))
// Use the fakeStreamableServer pattern like other tests to avoid race conditions.
ctx := context.Background()