From 61245c67bd6b96b07698970109dd70831f0c04f8 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 25 Oct 2025 18:10:42 +0200 Subject: [PATCH] fix(websocket): use debug level for http.Server errors https://github.com/libp2p/go-libp2p/pull/3364 migrated from zap to slog but accidentally changed the log level for http.Server.ErrorLog from implicit INFO to explicit ERROR. This caused client EOF and TLS handshake errors to spam error logs and stdout in apps which log only ERROR by default. These http.Server errors (client EOFs, TLS handshake failures from clients with naive TLS implementations, connection timeouts from clients that abort early) are normal operational noise, not actual server errors. Using LevelDebug: - matches semantic meaning (similar to existing connection timeout logs) - respects user's configured threshold (default ERROR filters them out) - allows users to enable for debugging via log level configuration Fixes https://github.com/ipfs/kubo/issues/11027 Fixes https://github.com/ipfs/kubo/issues/11033 --- p2p/transport/websocket/listener.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/p2p/transport/websocket/listener.go b/p2p/transport/websocket/listener.go index 7de1f42cf4..45cfcfa22e 100644 --- a/p2p/transport/websocket/listener.go +++ b/p2p/transport/websocket/listener.go @@ -126,8 +126,10 @@ func newListener(a ma.Multiaddr, tlsConf *tls.Config, sharedTcp *tcpreuse.ConnMg }, } ln.server = http.Server{ - Handler: ln, - ErrorLog: slog.NewLogLogger(log.Handler(), slog.LevelError), + Handler: ln, + // Use LevelDebug for http.Server errors (TLS handshake failures, connection issues). + // These are operational noise from misbehaving/buggy remote clients, not server errors. + ErrorLog: slog.NewLogLogger(log.Handler(), slog.LevelDebug), ConnContext: ln.ConnContext, TLSConfig: tlsConf, }