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:
parent
ea161959d7
commit
755b9ed4df
1 changed files with 34 additions and 16 deletions
|
|
@ -626,7 +626,10 @@ func TestServerTransportCleanup(t *testing.T) {
|
|||
|
||||
handler := NewStreamableHTTPHandler(func(*http.Request) *Server { return server }, nil)
|
||||
handler.onTransportDeletion = func(sessionID string) {
|
||||
chans[sessionID] <- struct{}{}
|
||||
mu.Lock()
|
||||
ch := chans[sessionID]
|
||||
mu.Unlock()
|
||||
ch <- struct{}{}
|
||||
}
|
||||
|
||||
httpServer := httptest.NewServer(mustNotPanic(t, handler))
|
||||
|
|
@ -658,7 +661,11 @@ func TestServerTransportCleanup(t *testing.T) {
|
|||
t.Cleanup(func() { _ = clientSession.Close() })
|
||||
}
|
||||
|
||||
for _, ch := range chans {
|
||||
mu.Lock()
|
||||
channels := slices.Collect(maps.Values(chans))
|
||||
mu.Unlock()
|
||||
|
||||
for _, ch := range channels {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
t.Errorf("did not capture transport deletion event from all session in 10 seconds")
|
||||
|
|
|
|||
Loading…
Reference in a new issue