mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-14 13:49:16 +01:00
add a defer/recover to scws WriteJson
This commit is contained in:
parent
5327258287
commit
7da7d06f09
@ -128,11 +128,23 @@ func (ws *WSState) RunUpdates(updateCh chan interface{}) {
|
||||
for update := range updateCh {
|
||||
shell := ws.GetShell()
|
||||
if shell != nil {
|
||||
shell.WriteJson(update)
|
||||
writeJsonProtected(shell, update)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func writeJsonProtected(shell *wsshell.WSShell, update any) {
|
||||
defer func() {
|
||||
r := recover()
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
log.Printf("[error] in scws RunUpdates WriteJson: %v\n", r)
|
||||
return
|
||||
}()
|
||||
shell.WriteJson(update)
|
||||
}
|
||||
|
||||
func (ws *WSState) ReplaceShell(shell *wsshell.WSShell) {
|
||||
ws.Lock.Lock()
|
||||
defer ws.Lock.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user