{"record":{"id":"1f14ec7e68ad3ade","repo":"wavetermdev/waveterm","slug":"getting-wsl-connection-status-w","errorCode":null,"errorMessage":"getting wsl connection status: %w","messagePattern":"getting wsl connection status: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-conn.go","lineNumber":98,"sourceCode":"\tif !strings.HasPrefix(name, \"wsl://\") {\n\t\t_, err := remote.ParseOpts(name)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot parse connection name: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc getAllConnStatus() ([]wshrpc.ConnStatus, error) {\n\tvar allResp []wshrpc.ConnStatus\n\tsshResp, err := wshclient.ConnStatusCommand(RpcClient, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting ssh connection status: %w\", err)\n\t}\n\tallResp = append(allResp, sshResp...)\n\twslResp, err := wshclient.WslStatusCommand(RpcClient, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting wsl connection status: %w\", err)\n\t}\n\tallResp = append(allResp, wslResp...)\n\treturn allResp, nil\n}\n\nfunc connStatusRun(cmd *cobra.Command, args []string) error {\n\tallResp, err := getAllConnStatus()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(allResp) == 0 {\n\t\tWriteStdout(\"no connections\\n\")\n\t\treturn nil\n\t}\n\tWriteStdout(\"%-30s %-12s\\n\", \"connection\", \"status\")\n\tWriteStdout(\"----------------------------------------------\\n\")\n\tfor _, conn := range allResp {\n\t\tstr := fmt.Sprintf(\"%-30s %-12s\", conn.Connection, conn.Status)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-conn.go#L80-L116","documentation":"Returned by getAllConnStatus when the WSL status RPC (wshclient.WslStatusCommand) fails while collecting the full list of SSH and WSL connections. It wraps the underlying RPC error with the \"getting wsh connection status\" prefix. The command cannot report connection status without both SSH and WSL responses, so it fails fast instead of returning partial data.","triggerScenarios":"Running `wsh conn status` (or `wsh conn disconnect --all` via connDisconnectAllRun) when WslStatusCommand returns an error: the underlying RPC times out, the wshserver side is unreachable, or the WSL status provider itself errors.","commonSituations":"No active connection/router to the server, a stale or dead RPC route, WSL not installed or misconfigured on Windows hosts, or RPC timeout under load.","solutions":["Check that a server connection is available and the RPC client (RpcClient) is connected before running the command","Re-run with a shorter/longer timeout or retry; transient RPC failures are common","Inspect the wrapped inner error (%w) for the root cause (timeout vs. transport vs. server-side failure)","On Windows, verify WSL is installed (`wsl --status`) and distros are healthy"],"exampleFix":"// before\nwslResp, err := wshclient.WslStatusCommand(RpcClient, nil)\nif err != nil {\n    return nil, fmt.Errorf(\"getting wsh connection status: %w\", err)\n}\n// after\nwslResp, err := wshclient.WslStatusCommand(RpcClient, nil)\nif err != nil {\n    log.Printf(\"wsl status unavailable, returning ssh-only status: %v\", err)\n    return allResp, nil // degrade gracefully instead of failing the whole listing\n}","handlingStrategy":"retry","validationCode":"if RpcClient == nil || RpcClient.RouteID == \"\" {\n    return fmt.Errorf(\"no rpc client connected; cannot fetch wsl status\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := getAllConnStatus()\nif err != nil {\n    var rpcErr *wshrpc.RpcError\n    if errors.As(err, &rpcErr) {\n        // retry or surface RPC-specific cause\n    }\n    return fmt.Errorf(\"conn status unavailable: %w\", err)\n}","preventionTips":["Ensure the RPC client is connected before invoking conn status commands","Retry transient RPC failures with backoff","Monitor WSL health on Windows hosts that depend on it","Log the wrapped inner error to distinguish timeout vs transport failures"],"tags":["cli","rpc","wsl","connection-status"],"backgroundTag":"rpc-call-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}