{"record":{"id":"947ff274f48a8c15","repo":"wavetermdev/waveterm","slug":"reading-terminal-output-w","errorCode":null,"errorMessage":"reading terminal output: %w","messagePattern":"reading terminal output: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-debugterm.go","lineNumber":103,"sourceCode":"\t\t\tWriteStdout(\"%s\", formatDebugTermDecode(termData))\n\t\t} else {\n\t\t\tWriteStdout(\"%s\", formatDebugTermHex(termData))\n\t\t}\n\t\treturn nil\n\t}\n\tif debugTermSize <= 0 {\n\t\treturn fmt.Errorf(\"size must be greater than 0\")\n\t}\n\tfullORef, err := resolveBlockArg()\n\tif err != nil {\n\t\treturn err\n\t}\n\trtn, err := wshclient.DebugTermCommand(RpcClient, wshrpc.CommandDebugTermData{\n\t\tBlockId: fullORef.OID,\n\t\tSize:    debugTermSize,\n\t}, &wshrpc.RpcOpts{Timeout: 2000})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading terminal output: %w\", err)\n\t}\n\ttermData, err := base64.StdEncoding.DecodeString(rtn.Data64)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"decoding terminal output: %w\", err)\n\t}\n\tvar output string\n\tif mode == DebugTermModeDecode {\n\t\toutput = formatDebugTermDecode(termData)\n\t} else {\n\t\toutput = formatDebugTermHex(termData)\n\t}\n\tWriteStdout(\"%s\", output)\n\treturn nil\n}\n\nfunc debugTermPreRun(cmd *cobra.Command, args []string) error {\n\tif debugTermStdin || debugTermInput != \"\" {\n\t\treturn nil","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-debugterm.go#L85-L121","documentation":"debugTermRun calls wshclient.DebugTermCommand with a 2000ms timeout to fetch raw terminal output for the given block. Any RPC failure — timeout, disconnected client, unknown block, backend error — is wrapped as 'reading terminal output'.","triggerScenarios":"The target block does not exist or is not a terminal; the RPC exceeds the 2-second timeout; the wsh connection to the Wave app is broken; the backend returns an error reading the term buffer.","commonSituations":"Passing a blockId/oref of a non-terminal block (editor/web); the terminal was closed between resolving the block and the RPC; slow/laggy Wave connection exceeding the 2s timeout; stale JWT after app restart.","solutions":["Confirm the block id resolves to a live terminal block (use `wsh ls` / block list)","Retry with a freshly connected wsh session (re-run inside the Wave tab)","Retry the command — a transient timeout may succeed on a second attempt","Verify the Wave app is running and the connection is healthy"],"exampleFix":"// before\nwsh debugterm 8f2a... --size 4096   # block was closed\n// after\n# re-open the terminal, get its current block id, then:\nwsh debugterm <current-blockid> --size 4096","handlingStrategy":"retry","validationCode":"// ensure the block exists and is a terminal before the RPC:\nmeta, err := wshclient.GetMetaCommand(RpcClient, fullORef.OID, nil)\nif err != nil || meta[\"view\"] != \"term\" {\n\treturn fmt.Errorf(\"block %s is not a live terminal\", fullORef.OID)\n}","typeGuard":null,"tryCatchPattern":"rtn, err := wshclient.DebugTermCommand(RpcClient, data, &wshrpc.RpcOpts{Timeout: 2000})\nif err != nil {\n\tif ctxErr := context.DeadlineExceeded; errors.Is(err, ctxErr) || strings.Contains(err.Error(), \"timeout\") {\n\t\t// retry once with a longer timeout\n\t\trtn, err = wshclient.DebugTermCommand(RpcClient, data, &wshrpc.RpcOpts{Timeout: 10000})\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading terminal output: %w\", err)\n\t}\n}","preventionTips":["Confirm the block id belongs to an open terminal before querying","Reconnect wsh (re-run inside the Wave tab) after app restarts","Retry transient timeouts; consider a longer timeout on slow connections","Keep wsh and Wave Terminal versions matched"],"tags":["rpc","timeout","cli","debug"],"backgroundTag":"rpc-timeout","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}