Skip to content

Commit

Permalink
Reduce web SSH session log spam (#49635)
Browse files Browse the repository at this point in the history
Prevents emitting error log messages when users exit SSH web
sessions under normal circumstances.

Closes #49394
  • Loading branch information
rosstimothy authored Dec 2, 2024
1 parent 8268985 commit f30af31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/web/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions lib/web/terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit f30af31

Please sign in to comment.