wavetermdev/waveterm · error
cannot open domain socket for %q when status is %q
Error message
cannot open domain socket for %q when status is %q
What it means
OpenDomainSocketListener may only run while the SSH connection is in the Status_Connecting state; the check is done under the connection lock. If the connection has already moved past (Connected, Connecting-again, Disconnected, etc.), opening the wsh domain socket listener is refused with this error.
Source
Thrown at pkg/remote/conncontroller/conncontroller.go:276
func (conn *SSHConn) GetStatus() string {
conn.lock.Lock()
defer conn.lock.Unlock()
return conn.Status
}
func (conn *SSHConn) GetName() string {
// no lock required because opts is immutable
return conn.Opts.String()
}
func (conn *SSHConn) OpenDomainSocketListener(ctx context.Context) error {
conn.Infof(ctx, "running OpenDomainSocketListener...\n")
allowed := WithLockRtn(conn, func() bool {
return conn.Status == Status_Connecting
})
if !allowed {
return fmt.Errorf("cannot open domain socket for %q when status is %q", conn.GetName(), conn.GetStatus())
}
client := conn.GetClient()
randStr, err := utilfn.RandomHexString(16) // 64-bits of randomness
if err != nil {
return fmt.Errorf("error generating random string: %w", err)
}
sockName := fmt.Sprintf("/tmp/waveterm-%s.sock", randStr)
conn.Infof(ctx, "generated domain socket name %s\n", sockName)
listener, err := client.ListenUnix(sockName)
if err != nil {
return fmt.Errorf("unable to request connection domain socket: %v", err)
}
conn.WithLock(func() {
conn.DomainSockName = sockName
conn.DomainSockListener = listener
})
conn.Infof(ctx, "successfully connected domain socket\n")
go func() {View on GitHub (pinned to a4447c1563)
Solutions
- Ensure OpenDomainSocketListener is invoked exactly once during the connecting phase (guard with a 'wsh tried' flag)
- Re-check conn.Status before calling and skip if it is not Status_Connecting
- If wsh is needed on an already-connected connection, restart the connection (disconnect/reconnect) so it re-enters Status_Connecting
Example fix
// before
conn.OpenDomainSocketListener(ctx) // status may already be Connected
// after
if conn.GetStatus() != remote.Status_Connecting {
return // or reconnect first
}
if err := conn.OpenDomainSocketListener(ctx); err != nil {
log.Printf("wsh socket skipped: %v", err)
} Defensive patterns
Strategy: validation
Validate before calling
if conn.GetStatus() != remote.Status_Connecting {
return fmt.Errorf("skip OpenDomainSocketListener: status is %s", conn.GetStatus())
} Try / catch
err := conn.OpenDomainSocketListener(ctx)
if err != nil && strings.Contains(err.Error(), "cannot open domain socket") {
log.Printf("wsh socket setup skipped: %v", err) // not fatal; skip
} Prevention
- Invoke OpenDomainSocketListener only from the connecting phase, exactly once
- Use a once-flag so tryEnableWsh cannot race itself
- If already connected, reconnect rather than forcing the listener
When it happens
Trigger: tryEnableWsh calls OpenDomainSocketListener after the connection status changed from Status_Connecting — e.g. a duplicate enable attempt, or the connection finished connecting meanwhile.
Common situations: wsh auto-enable racing with connection establishment; calling tryEnableWsh twice on the same connection; attempting wsh enable on an already-connected or disconnected connection.
Related errors
- getting ssh connection status: %w
- ssh connection not found: %s
- ssh connection %s not connected, cannot start shellproc
- unable to request connection domain socket: %v
- unexpected version format: %s
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/85abdacf72d0ee9f.
Report an issue: GitHub.