From b4aeb80ae3ac7edc771342348914ee1d55c9ae6e Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Mon, 10 Feb 2025 15:54:14 -0800 Subject: [PATCH] Add panic handler to sendrpcmessage to catch channel errors (#1938) --- pkg/wshutil/wshproxy.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/wshutil/wshproxy.go b/pkg/wshutil/wshproxy.go index 0bc5ae088..f1b9c8305 100644 --- a/pkg/wshutil/wshproxy.go +++ b/pkg/wshutil/wshproxy.go @@ -9,6 +9,7 @@ import ( "sync" "github.com/google/uuid" + "github.com/wavetermdev/waveterm/pkg/panichandler" "github.com/wavetermdev/waveterm/pkg/util/shellutil" "github.com/wavetermdev/waveterm/pkg/util/utilfn" "github.com/wavetermdev/waveterm/pkg/wshrpc" @@ -247,7 +248,11 @@ func (p *WshRpcProxy) HandleAuthentication() (*wshrpc.RpcContext, error) { } } +// TODO: Figure out who is sending to closed routes and why we're not catching it func (p *WshRpcProxy) SendRpcMessage(msg []byte) { + defer func() { + panichandler.PanicHandler("WshRpcProxy.SendRpcMessage", recover()) + }() p.ToRemoteCh <- msg }