wavetermdev/waveterm · error
<resp.Error>
Error message
<resp.Error>
What it means
WshRpc responses carry an Error string; when the remote handler returns an error, the client converts it with errors.New(resp.Error). So this message is arbitrary — it is the exact error text produced by the remote wsh command implementation, relayed to the caller.
Source
Thrown at pkg/wshutil/wshrpc.go:605
return false
default:
return false
}
}
func (handler *RpcRequestHandler) NextResponse() (any, error) {
var resp *RpcMessage
if handler.cachedResp != nil {
resp = handler.cachedResp
handler.cachedResp = nil
} else {
resp = <-handler.respCh
}
if resp == nil {
return nil, errors.New("response channel closed")
}
if resp.Error != "" {
return nil, errors.New(resp.Error)
}
return resp.Data, nil
}
func (handler *RpcRequestHandler) finalize() {
handler.callContextCancelFn()
if handler.reqId != "" {
handler.w.unregisterRpc(handler.reqId, nil)
}
}
func (handler *RpcRequestHandler) callContextCancelFn() {
cancelFnPtr := handler.ctxCancelFn.Swap(nil)
if cancelFnPtr != nil && *cancelFnPtr != nil {
(*cancelFnPtr)()
}
}
View on GitHub (pinned to a4447c1563)
Solutions
- Read the error text — it names the actual remote failure; fix the root cause on the handler side.
- Validate inputs (paths, IDs, options) before sending the RPC.
- Check remote-side logs for the originating error in the command handler.
- Handle per-command error semantics in your caller instead of treating it as a transport bug.
- Ensure both client and server use compatible protocol versions to avoid handler mismatches.
Example fix
// before
_, err := wshclient.CommandRun(connCtx, req)
if err != nil { return err } // opaque remote error
// after
_, err := wshclient.CommandRun(connCtx, req)
if err != nil {
return fmt.Errorf("remote command failed: %w", err) // err.Error() == the handler's message
} Defensive patterns
Strategy: try-catch
Validate before calling
// validate inputs the remote handler checks (paths exist, IDs valid) before calling the RPC
Try / catch
out, err := client.SendRpc(command, args, opts)
if err != nil {
return fmt.Errorf("%s failed on remote: %w", command, err) // err text == handler's message
} Prevention
- Read the error string — it names the remote root cause.
- Keep handler error messages actionable and prefixed with the command name.
- Validate remote resources exist before invoking.
- Keep client/server protocol versions in sync.
When it happens
Trigger: Any wsh RPC whose server-side handler returns an error: the client-side call (e.g. SendRpc/SendComplexRequest followed by Wait) returns errors.New(resp.Error) with the handler's error message verbatim.
Common situations: File operations failing on the remote (missing file, permission denied); blockcontroller commands on invalid block IDs; any application-level validation error raised inside the remote command handler.
Related errors
- msg.error
- nil wshrpc passed to wshclient
- no default route
- response channel closed
- server is no longer running, cannot send new requests
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/d67feb1b40ead539.
Report an issue: GitHub.