diff --git a/hub_test.go b/hub_test.go index abe6903..9b53939 100644 --- a/hub_test.go +++ b/hub_test.go @@ -284,7 +284,8 @@ func WaitForHub(ctx context.Context, t *testing.T, h *Hub) { case <-ctx.Done(): h.mu.Lock() h.ru.Lock() - t.Errorf("Error waiting for clients %+v / rooms %+v / sessions %+v to terminate: %s", h.clients, h.rooms, h.sessions, ctx.Err()) + dumpGoroutines() + t.Errorf("Error waiting for clients %+v / rooms %+v / sessions %+v / %d read / %d write to terminate: %s", h.clients, h.rooms, h.sessions, readActive, writeActive, ctx.Err()) h.ru.Unlock() h.mu.Unlock() return diff --git a/testutils_test.go b/testutils_test.go index bcc781f..296e328 100644 --- a/testutils_test.go +++ b/testutils_test.go @@ -68,7 +68,12 @@ func ensureNoGoroutinesLeak(t *testing.T, f func(t *testing.T)) { } if after != before { - profile.WriteTo(os.Stderr, 2) // nolint + dumpGoroutines() t.Fatalf("Number of Go routines has changed from %d to %d", before, after) } } + +func dumpGoroutines() { + profile := pprof.Lookup("goroutine") + profile.WriteTo(os.Stderr, 2) // nolint +}