{"record":{"id":"1304d1bc64ef13ad","repo":"wavetermdev/waveterm","slug":"error-getting-terminal-scrollback-w","errorCode":null,"errorMessage":"error getting terminal scrollback: %w","messagePattern":"error getting terminal scrollback: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-termscrollback.go","lineNumber":83,"sourceCode":"\t// Check if the block is a terminal block\n\tviewType, ok := metaData[waveobj.MetaKey_View].(string)\n\tif !ok || viewType != \"term\" {\n\t\treturn fmt.Errorf(\"block %s is not a terminal block (view type: %s)\", fullORef.OID, viewType)\n\t}\n\n\t// Make the RPC call to get scrollback\n\tscrollbackData := wshrpc.CommandTermGetScrollbackLinesData{\n\t\tLineStart:   termScrollbackLineStart,\n\t\tLineEnd:     termScrollbackLineEnd,\n\t\tLastCommand: termScrollbackLastCmd,\n\t}\n\n\tresult, err := wshclient.TermGetScrollbackLinesCommand(RpcClient, scrollbackData, &wshrpc.RpcOpts{\n\t\tRoute:   wshutil.MakeFeBlockRouteId(fullORef.OID),\n\t\tTimeout: 5000,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting terminal scrollback: %w\", err)\n\t}\n\n\t// Format the output\n\toutput := strings.Join(result.Lines, \"\\n\")\n\tif len(result.Lines) > 0 {\n\t\toutput += \"\\n\" // Add final newline\n\t}\n\n\t// Write to file or stdout\n\tif termScrollbackOutputFile != \"\" {\n\t\terr = os.WriteFile(termScrollbackOutputFile, []byte(output), 0644)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error writing to file %s: %w\", termScrollbackOutputFile, err)\n\t\t}\n\t\tfmt.Printf(\"terminal scrollback written to %s (%d lines)\\n\", termScrollbackOutputFile, len(result.Lines))\n\t} else {\n\t\tfmt.Print(output)\n\t}","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-termscrollback.go#L65-L101","documentation":"wsh requests scrollback lines via TermGetScrollbackLinesCommand routed to the frontend block route (MakeFeBlockRouteId). If this RPC fails — block not found on the route, timeout (5000ms), or the frontend never answers — this wrapper is returned.","triggerScenarios":"TermGetScrollbackLinesCommand error: no frontend handler for the block route, block closed mid-call, or 5s timeout exceeded for large scrollback ranges.","commonSituations":"Requesting a line range that overwhelms the frontend; the terminal block was closed between metadata check and the scrollback call; Wave app busy or hung.","solutions":["Retry, narrowing the LineStart/LineEnd range to fetch fewer lines.","Confirm the terminal block is still open in the Wave app.","Ensure the Wave app is responsive; restart it if the frontend route is unresponsive."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// keep the requested range small before the RPC\nif termScrollbackLineEnd-termScrollbackLineStart > 10000 {\n\tfmt.Fprintln(os.Stderr, \"requested scrollback range too large; narrow the range\")\n\tos.Exit(1)\n}","typeGuard":null,"tryCatchPattern":"result, err := wshclient.TermGetScrollbackLinesCommand(RpcClient, scrollbackData, &wshrpc.RpcOpts{\n\tRoute:   wshutil.MakeFeBlockRouteId(fullORef.OID),\n\tTimeout: 5000,\n})\nif err != nil {\n\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t// retry once with a smaller range or longer timeout\n\t}\n\treturn fmt.Errorf(\"error getting terminal scrollback: %w\", err)\n}","preventionTips":["Request modest line ranges instead of the entire scrollback.","Ensure the terminal block stays open until the call completes.","Avoid running while the Wave app is heavily loaded."],"tags":["rpc","timeout","terminal"],"backgroundTag":"rpc-timeout","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}