wavetermdev/waveterm · error

error getting terminal scrollback: %w

Error message

error getting terminal scrollback: %w

What it means

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.

Source

Thrown at cmd/wsh/cmd/wshcmd-termscrollback.go:83

	// Check if the block is a terminal block
	viewType, ok := metaData[waveobj.MetaKey_View].(string)
	if !ok || viewType != "term" {
		return fmt.Errorf("block %s is not a terminal block (view type: %s)", fullORef.OID, viewType)
	}

	// Make the RPC call to get scrollback
	scrollbackData := wshrpc.CommandTermGetScrollbackLinesData{
		LineStart:   termScrollbackLineStart,
		LineEnd:     termScrollbackLineEnd,
		LastCommand: termScrollbackLastCmd,
	}

	result, err := wshclient.TermGetScrollbackLinesCommand(RpcClient, scrollbackData, &wshrpc.RpcOpts{
		Route:   wshutil.MakeFeBlockRouteId(fullORef.OID),
		Timeout: 5000,
	})
	if err != nil {
		return fmt.Errorf("error getting terminal scrollback: %w", err)
	}

	// Format the output
	output := strings.Join(result.Lines, "\n")
	if len(result.Lines) > 0 {
		output += "\n" // Add final newline
	}

	// Write to file or stdout
	if termScrollbackOutputFile != "" {
		err = os.WriteFile(termScrollbackOutputFile, []byte(output), 0644)
		if err != nil {
			return fmt.Errorf("error writing to file %s: %w", termScrollbackOutputFile, err)
		}
		fmt.Printf("terminal scrollback written to %s (%d lines)\n", termScrollbackOutputFile, len(result.Lines))
	} else {
		fmt.Print(output)
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Retry, narrowing the LineStart/LineEnd range to fetch fewer lines.
  2. Confirm the terminal block is still open in the Wave app.
  3. Ensure the Wave app is responsive; restart it if the frontend route is unresponsive.
Defensive patterns

Strategy: retry

Validate before calling

// keep the requested range small before the RPC
if termScrollbackLineEnd-termScrollbackLineStart > 10000 {
	fmt.Fprintln(os.Stderr, "requested scrollback range too large; narrow the range")
	os.Exit(1)
}

Try / catch

result, err := wshclient.TermGetScrollbackLinesCommand(RpcClient, scrollbackData, &wshrpc.RpcOpts{
	Route:   wshutil.MakeFeBlockRouteId(fullORef.OID),
	Timeout: 5000,
})
if err != nil {
	if errors.Is(err, context.DeadlineExceeded) {
		// retry once with a smaller range or longer timeout
	}
	return fmt.Errorf("error getting terminal scrollback: %w", err)
}

Prevention

When it happens

Trigger: TermGetScrollbackLinesCommand error: no frontend handler for the block route, block closed mid-call, or 5s timeout exceeded for large scrollback ranges.

Common situations: 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.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/1304d1bc64ef13ad. Report an issue: GitHub.