From ef371ba6a83fe946474ca3833ebc88812b070faa Mon Sep 17 00:00:00 2001 From: Tim Ross Date: Wed, 27 Nov 2024 16:09:40 -0500 Subject: [PATCH] Reduce web SSH session log spam Prevents emitting error log messages when users exit SSH web sessions under normal circumstances. Closes https://github.com/gravitational/teleport/issues/49394 --- lib/web/terminal.go | 2 +- lib/web/terminal/terminal.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/web/terminal.go b/lib/web/terminal.go index 6b06a53832c3d..f1a674a927dde 100644 --- a/lib/web/terminal.go +++ b/lib/web/terminal.go @@ -875,7 +875,7 @@ func (t *TerminalHandler) streamTerminal(ctx context.Context, tc *client.Telepor t.log.WithError(err).Error("Unable to send close event to web client.") } - if err := t.stream.Close(); err != nil { + if err := t.stream.Close(); err != nil && !errors.Is(err, io.EOF) { t.log.WithError(err).Error("Unable to close client web socket.") return } diff --git a/lib/web/terminal/terminal.go b/lib/web/terminal/terminal.go index c92dae03fb2d1..b455fc9eb7287 100644 --- a/lib/web/terminal/terminal.go +++ b/lib/web/terminal/terminal.go @@ -115,8 +115,8 @@ func (t *WSStream) WriteMessage(messageType int, data []byte) error { // WriteError displays an error in the terminal window. func (t *WSStream) WriteError(msg string) { - if _, writeErr := replacer.WriteString(t, msg); writeErr != nil { - t.log.WithError(writeErr).Warnf("Unable to send error to terminal: %v", msg) + if _, err := replacer.WriteString(t, msg); err != nil && !errors.Is(err, websocket.ErrCloseSent) { + t.log.WithError(err).Warnf("Unable to send error to terminal: %v", msg) } }