Skip to content

Commit

Permalink
Reduce web SSH session log spam
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 and github-actions committed Dec 2, 2024
1 parent 05a9fd4 commit 6e9ef7f
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 @@ -894,7 +894,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 6e9ef7f

Please sign in to comment.