fix: Fix the problem that the terminal exit fails (#8189)
Some checks failed
SonarCloud Scan / SonarCloud (push) Failing after -28s

This commit is contained in:
ssongliu 2025-03-19 11:43:21 +08:00 committed by GitHub
parent 99775e1eb4
commit 79eb0288b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 10 deletions

View file

@ -68,9 +68,8 @@ func (b *BaseApi) WsSsh(c *gin.Context) {
<-quitChan <-quitChan
if wshandleError(wsConn, err) { dt := time.Now().Add(time.Second)
return _ = wsConn.WriteControl(websocket.CloseMessage, nil, dt)
}
} }
func (b *BaseApi) ContainerWsSSH(c *gin.Context) { func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
@ -133,9 +132,9 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
<-quitChan <-quitChan
global.LOG.Info("websocket finished") global.LOG.Info("websocket finished")
if wshandleError(wsConn, err) { dt := time.Now().Add(time.Second)
return _ = wsConn.WriteControl(websocket.CloseMessage, nil, dt)
}
} }
func loadRedisInitCmd(c *gin.Context) (string, string, error) { func loadRedisInitCmd(c *gin.Context) (string, string, error) {

View file

@ -100,4 +100,5 @@ func (lcmd *LocalCommand) Wait(quitChan chan bool) {
global.LOG.Errorf("ssh session wait failed, err: %v", err) global.LOG.Errorf("ssh session wait failed, err: %v", err)
setQuit(quitChan) setQuit(quitChan)
} }
setQuit(quitChan)
} }

View file

@ -85,7 +85,9 @@ function onClose(isKeepShow: boolean = false) {
term.value.dispose(); term.value.dispose();
} catch {} } catch {}
} }
terminalElement.value.innerHTML = ''; if (terminalElement.value) {
terminalElement.value.innerHTML = '';
}
} }
// terminal start // terminal start
@ -202,10 +204,10 @@ const errorRealTerminal = (ex: any) => {
const closeRealTerminal = (ev: CloseEvent) => { const closeRealTerminal = (ev: CloseEvent) => {
if (heartbeatTimer.value) { if (heartbeatTimer.value) {
clearInterval(heartbeatTimer.value); clearInterval(Number(heartbeatTimer.value));
} }
term.value.write('The connection has been disconnected.'); term.value?.write('The connection has been disconnected.');
term.value.write(ev.reason); term.value?.write(ev.reason);
}; };
const isWsOpen = () => { const isWsOpen = () => {