Skip to content

Commit

Permalink
Display websocket errors in the UI (#43433)
Browse files Browse the repository at this point in the history
We never implemented UI support for the websocket error message,
so errors were never surfaced to users.

This also uncovered one case where we were sending invalid data
(due to a missing version number).

Closes #42626
  • Loading branch information
zmb3 authored Jun 25, 2024
1 parent 1e2d772 commit 0fd1da7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4157,6 +4157,7 @@ func (h *Handler) writeErrToWebSocket(ws *websocket.Conn, err error) {
return
}
errEnvelope := terminal.Envelope{
Version: defaults.WebsocketVersion,
Type: defaults.WebsocketError,
Payload: trace.UserMessage(err),
}
Expand Down
2 changes: 2 additions & 0 deletions web/packages/teleport/src/lib/term/protobuf.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const MessageTypeEnum = {
FILE_TRANSFER_REQUEST: 'f',
FILE_TRANSFER_DECISION: 't',
WEBAUTHN_CHALLENGE: 'n',
ERROR: 'e',
LATENCY: 'l',
KUBE_EXEC: 'k',
};
Expand Down Expand Up @@ -62,6 +63,7 @@ export const messageFields = {
close: MessageTypeEnum.SESSION_END.charCodeAt(0),
challengeResponse: MessageTypeEnum.WEBAUTHN_CHALLENGE.charCodeAt(0),
kubeExec: MessageTypeEnum.KUBE_EXEC.charCodeAt(0),
error: MessageTypeEnum.ERROR.charCodeAt(0),
},
},
};
Expand Down
3 changes: 3 additions & 0 deletions web/packages/teleport/src/lib/term/tty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ class Tty extends EventEmitterWebAuthnSender {
this.emit(TermEvent.DATA, msg.payload);
}
break;
case MessageTypeEnum.ERROR:
this.emit(TermEvent.DATA, msg.payload + '\n');
break;
case MessageTypeEnum.LATENCY:
this.emit(TermEvent.LATENCY, msg.payload);
break;
Expand Down

0 comments on commit 0fd1da7

Please sign in to comment.