wavetermdev/waveterm · error

error setting up rpc client: %w

Error message

error setting up rpc client: %w

What it means

tokenCmdRun calls setupRpcClientWithToken to build an RPC client authenticated with the provided token. If that setup fails — invalid token, no running Wave app to connect to, connection/route errors — the cause is wrapped as 'error setting up rpc client'.

Source

Thrown at cmd/wsh/cmd/wshcmd-token.go:36

}

func init() {
	rootCmd.AddCommand(tokenCmd)
}

func tokenCmdRun(cmd *cobra.Command, args []string) (rtnErr error) {
	if len(args) != 2 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("wsh token requires exactly 2 arguments, got %d", len(args))
	}
	tokenStr, shellType := args[0], args[1]
	if tokenStr == "" || shellType == "" {
		OutputHelpMessage(cmd)
		return fmt.Errorf("wsh token requires non-empty arguments")
	}
	rtnData, err := setupRpcClientWithToken(tokenStr)
	if err != nil {
		return fmt.Errorf("error setting up rpc client: %w", err)
	}
	envScriptText, err := shellutil.EncodeEnvVarsForShell(shellType, rtnData.Env)
	if err != nil {
		return fmt.Errorf("error encoding env vars: %w", err)
	}
	WriteStdout("%s\n", envScriptText)
	WriteStdout("%s\n", rtnData.InitScriptText)
	return nil
}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Regenerate the token from the Wave app (it rotates per session) and retry.
  2. Confirm the Wave app is running and reachable from this shell.
  3. Inspect the wrapped %w error to distinguish auth rejection from connection failure.
Defensive patterns

Strategy: retry

Validate before calling

# confirm connectivity before the token command
curl -sf http://localhost:${WAVE_PORT:-$(default_wave_port)} >/dev/null || echo "Wave app not reachable"

Try / catch

rtnData, err := setupRpcClientWithToken(tokenStr)
if err != nil {
	if errors.Is(err, context.DeadlineExceeded) {
		// app not responding: retry after restarting Wave
	}
	// invalid token: fetch a fresh token from the Wave app
	return fmt.Errorf("error setting up rpc client: %w", err)
}

Prevention

When it happens

Trigger: setupRpcClientWithToken returning an error: token rejected/expired, no Wave app listening, network or route resolution failure during client handshake.

Common situations: Copy-pasting a stale token from an old session; running the command on a machine where Wave isn't running; token rotated after Wave restart.

Related errors


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