hashicorp/nomad · error

failed to start stream: %v

Error message

failed to start stream: %v

What it means

After acquiring a conn, getRPCClient obtains a yamux-backed RPC client from the connection. If that fails, it retries once (redialing, since the TCP session may have timed out); if the retry also fails, it returns 'failed to start stream: <err>'.

Source

Thrown at helper/pool/pool.go:486

START:
	// Try to get a conn first
	conn, err := p.acquire(region, addr)
	if err != nil {
		return nil, nil, fmt.Errorf("failed to get conn: %v", err)
	}

	// Get a client
	client, err := conn.getRPCClient()
	if err != nil {
		p.clearConn(conn)
		conn.releaseUse()

		// Try to redial, possible that the TCP session closed due to timeout
		if retries == 0 {
			retries++
			goto START
		}
		return nil, nil, fmt.Errorf("failed to start stream: %v", err)
	}
	return conn, client, nil
}

// StreamingRPC is used to make an streaming RPC call.  Callers must
// close the connection when done.
func (p *ConnPool) StreamingRPC(region string, addr net.Addr) (net.Conn, error) {
	conn, err := p.acquire(region, addr)
	if err != nil {
		return nil, fmt.Errorf("failed to get conn: %v", err)
	}

	s, err := conn.session.Open()
	if err != nil {
		return nil, fmt.Errorf("failed to open a streaming connection: %v", err)
	}

	if _, err := s.Write([]byte{byte(RpcStreaming)}); err != nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check inner error; session resets usually indicate idle timeouts — tune conn pool/keepalive settings
  2. Verify server stability (crashes/OOM close sessions mid-handshake)
  3. Retry the RPC at a higher level; persistent failure means investigate the network path
Defensive patterns

Strategy: retry

Try / catch

err := pool.RPC(region, addr, method, args, out)
if err != nil && strings.Contains(err.Error(), "failed to start stream") {
    // pool already retried once internally; retry once more after backoff
    time.Sleep(250 * time.Millisecond)
    return pool.RPC(region, addr, method, args, out)
}

Prevention

When it happens

Trigger: pool.RPC -> getRPCClient where conn.getRPCClient errors on both the initial attempt and the single retry (retries>0 path).

Common situations: Stale yamux sessions killed by idle timeouts, server closing connections mid-handshake, heavy load causing stream setup failures twice in a row.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/1f8603381f029b01. Report an issue: GitHub.