Skip to content

Commit e03703c

Browse files
committed
replace WaitGroup with Sleep
1 parent cf2eac3 commit e03703c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mcp/streamable_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,12 @@ func TestStreamableClientConnSSEGoroutineLeak(t *testing.T) {
617617
}
618618

619619
// Start the handleSSE goroutine manually
620-
go conn.handleSSE(resp)
620+
var wg sync.WaitGroup
621+
wg.Add(1)
622+
go func() {
623+
conn.handleSSE(resp)
624+
wg.Done()
625+
}()
621626

622627
// Wait until incoming channel is filled
623628
deadlineCtx, cancelFunc := context.WithTimeout(context.Background(), 100*time.Millisecond)
@@ -633,7 +638,7 @@ func TestStreamableClientConnSSEGoroutineLeak(t *testing.T) {
633638

634639
// Now simulate calling Close() and blocking the goroutine
635640
close(conn.done)
636-
time.Sleep(50 * time.Millisecond) // Allow goroutine to exit
641+
wg.Wait()
637642

638643
// Check if "scanEvents" goroutine is still running
639644
leakKey := "scanEvents"

0 commit comments

Comments
 (0)