wavetermdev/waveterm · error

connection %q is not connected

Error message

connection %q is not connected

What it means

CheckJobConnected returns this error when conncontroller.IsConnected answers definitively that the job's connection is not currently connected. The job and connection exist, but the underlying transport (e.g. SSH) is down.

Source

Thrown at pkg/jobcontroller/jobcontroller.go:592

		if status == JobConnStatus_Connected {
			count++
		}
	}
	return count
}

func CheckJobConnected(ctx context.Context, jobId string) (*waveobj.Job, error) {
	job, err := wstore.DBMustGet[*waveobj.Job](ctx, jobId)
	if err != nil {
		return nil, fmt.Errorf("failed to get job: %w", err)
	}

	isConnected, err := conncontroller.IsConnected(job.Connection)
	if err != nil {
		return nil, fmt.Errorf("error checking connection status: %w", err)
	}
	if !isConnected {
		return nil, fmt.Errorf("connection %q is not connected", job.Connection)
	}

	jobConnStatus := GetJobConnStatus(jobId)
	if jobConnStatus != JobConnStatus_Connected {
		return nil, fmt.Errorf("job is not connected (status: %s)", jobConnStatus)
	}

	return job, nil
}

type StartJobParams struct {
	ConnName string
	JobKind  string
	Cmd      string
	Args     []string
	Env      map[string]string
	TermSize *waveobj.TermSize
	BlockId  string

View on GitHub (pinned to a4447c1563)

Solutions

  1. Reconnect the connection (wait for doReconnectJob or trigger reconnection)
  2. Check network/SSH reachability of the remote host
  3. Retry once the connection reports connected
  4. Route input through a queue and flush when reconnected

Example fix

// before
_, err := jobcontroller.CheckJobConnected(ctx, jobId)
if err != nil {
	return err
}
// after
_, err := jobcontroller.CheckJobConnected(ctx, jobId)
if err != nil {
	var connErr *jobcontroller.NotConnectedError // or message check
	if strings.Contains(err.Error(), "is not connected") {
		<-reconnectedCh
		_, err = jobcontroller.CheckJobConnected(ctx, jobId)
	}
	if err != nil {
		return err
	}
}
Defensive patterns

Strategy: retry

Validate before calling

isConn, _ := conncontroller.IsConnected(connName)
if !isConn {
	return fmt.Errorf("pre-flight: connection %s down; reconnect first", connName)
}

Type guard

func isNotConnectedErr(err error) bool {
	return err != nil && strings.Contains(err.Error(), "is not connected")
}

Try / catch

_, err := jobcontroller.CheckJobConnected(ctx, jobId)
if isNotConnectedErr(err) {
	select {
	case <-reconnectedCh:
		_, err = jobcontroller.CheckJobConnected(ctx, jobId)
	case <-time.After(10 * time.Second):
		return fmt.Errorf("timed out waiting for reconnection")
	}
}
if err != nil { return err }

Prevention

When it happens

Trigger: Calling CheckJobConnected (via doReconnectJob or SendInput) when the job's connection is configured but disconnected — dropped SSH session, remote host unreachable, or connection not yet established.

Common situations: Laptop slept and SSH dropped; remote host rebooted; network switch/VPN down; trying to send input before the remote shell connects.

Related errors


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