From 68b1bbdaaf0cbb4c9d573168e4ad4c26a0eb6f1b Mon Sep 17 00:00:00 2001 From: guillaumemichel Date: Wed, 7 May 2025 09:55:03 +0200 Subject: [PATCH] update slow consumer event error to warn --- p2p/host/eventbus/basic.go | 3 ++- p2p/host/eventbus/basic_test.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/p2p/host/eventbus/basic.go b/p2p/host/eventbus/basic.go index af6a74bd02..32051f54fb 100644 --- a/p2p/host/eventbus/basic.go +++ b/p2p/host/eventbus/basic.go @@ -14,6 +14,7 @@ import ( type logInterface interface { Errorf(string, ...interface{}) + Warnf(string, ...interface{}) } var log logInterface = logging.Logger("eventbus") @@ -464,7 +465,7 @@ func emitAndLogError(timer *time.Timer, typ reflect.Type, evt interface{}, sink <-timer.C } case <-timer.C: - log.Errorf("subscriber named \"%s\" is a slow consumer of %s. This can lead to libp2p stalling and hard to debug issues.", sink.name, typ) + log.Warnf("subscriber named \"%s\" is a slow consumer of %s. This can lead to libp2p stalling and hard to debug issues.", sink.name, typ) // Continue to stall since there's nothing else we can do. sink.ch <- evt } diff --git a/p2p/host/eventbus/basic_test.go b/p2p/host/eventbus/basic_test.go index 530a46ff19..b3fdb12e35 100644 --- a/p2p/host/eventbus/basic_test.go +++ b/p2p/host/eventbus/basic_test.go @@ -18,8 +18,10 @@ import ( "github.com/stretchr/testify/require" ) -type EventA struct{} -type EventB int +type ( + EventA struct{} + EventB int +) func getN() int { n := 50000 @@ -144,6 +146,10 @@ func (m *mockLogger) Errorf(format string, args ...interface{}) { m.logs = append(m.logs, fmt.Sprintf(format, args...)) } +func (m *mockLogger) Warnf(format string, args ...interface{}) { + m.Errorf(format, args...) +} + func (m *mockLogger) Logs() []string { m.mu.Lock() defer m.mu.Unlock()