Skip to content

Commit 2175dfa

Browse files
fix[backend](soar_commands): handled writting errors on socket response
1 parent e10178a commit 2175dfa

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

backend/modules/soar/handler/command_ws.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ func (h *CommandWSHandler) CommandStream(c *gin.Context) {
173173
if writeErr := wsjson.Write(ctx, conn, wsMessage{Type: "output", Data: output}); writeErr != nil {
174174
return
175175
}
176-
_ = wsjson.Write(ctx, conn, wsMessage{Type: "done"})
177-
_ = conn.Close(websocket.StatusNormalClosure, "command complete")
176+
err := wsjson.Write(ctx, conn, wsMessage{Type: "done"})
177+
if err!=nil{
178+
_ = catcher.Error("Writting final message error", err, nil)
179+
}
180+
close_err := conn.Close(websocket.StatusNormalClosure, "command complete")
181+
if close_err!=nil{
182+
_ = catcher.Error("error closing ws channel", close_err, nil)
183+
}
178184
return
179185

180186
case grpcErr, ok := <-errCh:

0 commit comments

Comments
 (0)