From 5ed703f7c3f482fe2b8c17df02d125d8f44e8f0e Mon Sep 17 00:00:00 2001 From: ssonglius11 Date: Wed, 8 May 2024 16:43:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20exit=20=E9=80=80=E5=87=BA=E5=90=8E?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=20panic=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/utils/terminal/ws_local_session.go | 5 +++++ backend/utils/terminal/ws_session.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/backend/utils/terminal/ws_local_session.go b/backend/utils/terminal/ws_local_session.go index cc5aa6c61..fb8271994 100644 --- a/backend/utils/terminal/ws_local_session.go +++ b/backend/utils/terminal/ws_local_session.go @@ -70,6 +70,11 @@ func (sws *LocalWsSession) masterWrite(data []byte) error { } func (sws *LocalWsSession) receiveWsMsg(exitCh chan bool) { + defer func() { + if r := recover(); r != nil { + global.LOG.Errorf("[xpack] A panic occurred during receive ws message, error message: %v", r) + } + }() wsConn := sws.wsConn defer setQuit(exitCh) defer global.LOG.Debug("thread of receive ws msg has exited now") diff --git a/backend/utils/terminal/ws_session.go b/backend/utils/terminal/ws_session.go index 7c30c65ab..c0e72a761 100644 --- a/backend/utils/terminal/ws_session.go +++ b/backend/utils/terminal/ws_session.go @@ -116,6 +116,11 @@ func (sws *LogicSshWsSession) Start(quitChan chan bool) { } func (sws *LogicSshWsSession) receiveWsMsg(exitCh chan bool) { + defer func() { + if r := recover(); r != nil { + global.LOG.Errorf("[xpack] A panic occurred during receive ws message, error message: %v", r) + } + }() wsConn := sws.wsConn defer setQuit(exitCh) for {