diff --git a/package-lock.json b/package-lock.json index 6f653bc1c4..f5604304b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "waveterm", - "version": "0.12.2-beta.4", + "version": "0.12.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "waveterm", - "version": "0.12.2-beta.4", + "version": "0.12.2", "hasInstallScript": true, "license": "Apache-2.0", "workspaces": [ diff --git a/pkg/web/ws.go b/pkg/web/ws.go index 84928d5d08..549b89a396 100644 --- a/pkg/web/ws.go +++ b/pkg/web/ws.go @@ -81,8 +81,13 @@ func getStringFromMap(jmsg map[string]any, key string) string { func processWSCommand(jmsg map[string]any, outputCh chan any, rpcInputCh chan []byte) { var rtnErr error + var cmdType string defer func() { - panicErr := panichandler.PanicHandler("processWSCommand", recover()) + panicCtx := "processWSCommand" + if cmdType != "" { + panicCtx = fmt.Sprintf("processWSCommand:%s", cmdType) + } + panicErr := panichandler.PanicHandler(panicCtx, recover()) if panicErr != nil { rtnErr = panicErr } @@ -97,6 +102,7 @@ func processWSCommand(jmsg map[string]any, outputCh chan any, rpcInputCh chan [] rtnErr = fmt.Errorf("cannot parse wscommand: %v", err) return } + cmdType = wsCommand.GetWSCommand() switch cmd := wsCommand.(type) { case *webcmd.SetBlockTermSizeWSCommand: data := wshrpc.CommandBlockInputData{ @@ -137,6 +143,9 @@ func processWSCommand(jmsg map[string]any, outputCh chan any, rpcInputCh chan [] if rpcMsg == nil { return } + if rpcMsg.Command != "" { + cmdType = fmt.Sprintf("%s:%s", cmdType, rpcMsg.Command) + } msgBytes, err := json.Marshal(rpcMsg) if err != nil { // this really should never fail since we just unmarshalled this value diff --git a/pkg/wshutil/wshproxy.go b/pkg/wshutil/wshproxy.go index f1b9c83056..be53a41b08 100644 --- a/pkg/wshutil/wshproxy.go +++ b/pkg/wshutil/wshproxy.go @@ -66,7 +66,7 @@ func (p *WshRpcProxy) sendResponseError(msg RpcMessage, sendErr error) { Error: sendErr.Error(), } respBytes, _ := json.Marshal(resp) - p.SendRpcMessage(respBytes) + p.SendRpcMessage(respBytes, "resp-error") } func (p *WshRpcProxy) sendAuthenticateResponse(msg RpcMessage, routeId string) { @@ -80,7 +80,7 @@ func (p *WshRpcProxy) sendAuthenticateResponse(msg RpcMessage, routeId string) { Data: wshrpc.CommandAuthenticateRtnData{RouteId: routeId}, } respBytes, _ := json.Marshal(resp) - p.SendRpcMessage(respBytes) + p.SendRpcMessage(respBytes, "auth-resp") } func (p *WshRpcProxy) sendAuthenticateTokenResponse(msg RpcMessage, entry *shellutil.TokenSwapEntry) { @@ -99,7 +99,7 @@ func (p *WshRpcProxy) sendAuthenticateTokenResponse(msg RpcMessage, entry *shell }, } respBytes, _ := json.Marshal(resp) - p.SendRpcMessage(respBytes) + p.SendRpcMessage(respBytes, "auth-token-resp") } func validateRpcContextFromAuth(newCtx *wshrpc.RpcContext) (string, error) { @@ -249,9 +249,13 @@ 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) { +func (p *WshRpcProxy) SendRpcMessage(msg []byte, debugStr string) { defer func() { - panichandler.PanicHandler("WshRpcProxy.SendRpcMessage", recover()) + panicCtx := "WshRpcProxy.SendRpcMessage" + if debugStr != "" { + panicCtx = fmt.Sprintf("%s:%s", panicCtx, debugStr) + } + panichandler.PanicHandler(panicCtx, recover()) }() p.ToRemoteCh <- msg } diff --git a/pkg/wshutil/wshrouter.go b/pkg/wshutil/wshrouter.go index 17185dd607..acf5632c3b 100644 --- a/pkg/wshutil/wshrouter.go +++ b/pkg/wshutil/wshrouter.go @@ -122,7 +122,7 @@ func (router *WshRouter) SendEvent(routeId string, event wps.WaveEvent) { // nothing to do return } - rpc.SendRpcMessage(msgBytes) + rpc.SendRpcMessage(msgBytes, "eventrecv") } func (router *WshRouter) handleNoRoute(msg RpcMessage) { @@ -173,7 +173,7 @@ func (router *WshRouter) handleAnnounceMessage(msg RpcMessage, input msgAndRoute // if we don't (we are the terminal router), then add it to our announced route map upstream := router.GetUpstreamClient() if upstream != nil { - upstream.SendRpcMessage(input.msgBytes) + upstream.SendRpcMessage(input.msgBytes, "announce-upstream") return } if msg.Source == input.fromRouteId { @@ -201,12 +201,12 @@ func (router *WshRouter) getAnnouncedRoute(routeId string) string { func (router *WshRouter) sendRoutedMessage(msgBytes []byte, routeId string) bool { rpc := router.GetRpc(routeId) if rpc != nil { - rpc.SendRpcMessage(msgBytes) + rpc.SendRpcMessage(msgBytes, "route") return true } upstream := router.GetUpstreamClient() if upstream != nil { - upstream.SendRpcMessage(msgBytes) + upstream.SendRpcMessage(msgBytes, "route-upstream") return true } else { // we are the upstream, so consult our announced routes map @@ -216,7 +216,7 @@ func (router *WshRouter) sendRoutedMessage(msgBytes []byte, routeId string) bool log.Printf("[router] no rpc for route id %q\n", routeId) return false } - rpc.SendRpcMessage(msgBytes) + rpc.SendRpcMessage(msgBytes, "route-local") return true } } @@ -321,7 +321,7 @@ func (router *WshRouter) RegisterRoute(routeId string, rpc AbstractRpcClient, sh if shouldAnnounce && !alreadyExists && router.GetUpstreamClient() != nil { announceMsg := RpcMessage{Command: wshrpc.Command_RouteAnnounce, Source: routeId} announceBytes, _ := json.Marshal(announceMsg) - router.GetUpstreamClient().SendRpcMessage(announceBytes) + router.GetUpstreamClient().SendRpcMessage(announceBytes, "route-announce") } for { msgBytes, ok := rpc.RecvRpcMessage() diff --git a/pkg/wshutil/wshrpc.go b/pkg/wshutil/wshrpc.go index 3b70ff4db5..8a90a0790e 100644 --- a/pkg/wshutil/wshrpc.go +++ b/pkg/wshutil/wshrpc.go @@ -40,7 +40,7 @@ type ServerImpl interface { } type AbstractRpcClient interface { - SendRpcMessage(msg []byte) + SendRpcMessage(msg []byte, debugStr string) RecvRpcMessage() ([]byte, bool) // blocking } @@ -103,7 +103,7 @@ func GetRpcResponseHandlerFromContext(ctx context.Context) *RpcResponseHandler { return rtn.(*RpcResponseHandler) } -func (w *WshRpc) SendRpcMessage(msg []byte) { +func (w *WshRpc) SendRpcMessage(msg []byte, debugStr string) { w.InputCh <- msg }