wavetermdev/waveterm · error

disconnecting %q error: %w

Error message

disconnecting %q error: %w

What it means

Returned by connDisconnectRun when the ConnDisconnectCommand RPC fails for the given connection name (10-second timeout). The wrapper identifies the connection with %q and wraps the underlying error. The disconnect itself did not complete on the server.

Source

Thrown at cmd/wsh/cmd/wshcmd-conn.go:155

		ConnName:   connName,
		LogBlockId: RpcContext.BlockId,
	}
	err := wshclient.ConnReinstallWshCommand(RpcClient, data, &wshrpc.RpcOpts{Timeout: 60000})
	if err != nil {
		return fmt.Errorf("reinstalling connection: %w", err)
	}
	WriteStdout("wsh reinstalled on connection %q\n", connName)
	return nil
}

func connDisconnectRun(cmd *cobra.Command, args []string) error {
	connName := args[0]
	if err := validateConnectionName(connName); err != nil {
		return err
	}
	err := wshclient.ConnDisconnectCommand(RpcClient, connName, &wshrpc.RpcOpts{Timeout: 10000})
	if err != nil {
		return fmt.Errorf("disconnecting %q error: %w", connName, err)
	}
	WriteStdout("disconnected %q\n", connName)
	return nil
}

func connDisconnectAllRun(cmd *cobra.Command, args []string) error {
	allConns, err := getAllConnStatus()
	if err != nil {
		return err
	}
	for _, conn := range allConns {
		if conn.Status != "connected" {
			continue
		}
		err := wshclient.ConnDisconnectCommand(RpcClient, conn.Connection, &wshrpc.RpcOpts{Timeout: 10000})
		if err != nil {
			WriteStdout("error disconnecting %q: %v\n", conn.Connection, err)
		} else {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the connection name with `wsh conn status`; correct any typo
  2. Retry once — transient RPC timeouts are common; if persistent, the server may be overloaded
  3. Check whether the connection is actually already disconnected (the goal may already be met)
  4. Inspect the wrapped inner error for the server-side root cause

Example fix

// before
wsh conn disconnect prod
could not disconnect
// after
wsh conn status   # confirm exact name
wsh conn disconnect myserver
Defensive patterns

Strategy: retry

Validate before calling

status, err := wshclient.ConnStatusCommand(RpcClient, nil)
if err == nil && !slices.ContainsFunc(status, func(c wshrpc.ConnStatusEntry) bool { return c.ConnName == connName && c.Connected }) {
    return nil // already disconnected, nothing to do
}

Try / catch

err := wshclient.ConnDisconnectCommand(RpcClient, connName, &wshrpc.RpcOpts{Timeout: 10000})
if err != nil {
    if errors.Is(err, context.DeadlineExceeded) {
        // one retry, then surface
    }
    return fmt.Errorf("disconnecting %q error: %w", connName, err)
}

Prevention

When it happens

Trigger: Running `wsh conn disconnect <conn>` when the RPC errors: connection does not exist server-side, timeout exceeded (10s), or the server rejects the disconnect request.

Common situations: Disconnecting an already-closed connection, typos in the connection name, slow/unresponsive server exceeding the 10s timeout.

Related errors


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