gastownhall/beads · error

identity: set control deadline: %w

Error message

identity: set control deadline: %w

What it means

After dialing, Identify sets an absolute read/write deadline on the control connection via conn.SetDeadline. This error means the deadline could not be applied to the connection — essentially only possible if the connection is already invalid/closed or the time value is unusable.

Source

Thrown at internal/storage/dbproxy/identity/control.go:50

	UpstreamID  string `json:"upstream_id"`
	PID         int    `json:"pid"`
	Birth       string `json:"birth"`
	DataPort    int    `json:"data_port"`
	ControlPort int    `json:"control_port"`
	MAC         string `json:"mac"`
}

// Identify authenticates to a proxy control listener and returns its identity.
func Identify(host string, controlPort int, secret string, timeout time.Duration) (*IdentReply, error) {
	addr := net.JoinHostPort(host, strconv.Itoa(controlPort))
	conn, err := net.DialTimeout("tcp", addr, timeout)
	if err != nil {
		return nil, fmt.Errorf("identity: dial control listener: %w", err)
	}
	defer func() { _ = conn.Close() }()

	if err := conn.SetDeadline(time.Now().Add(timeout)); err != nil {
		return nil, fmt.Errorf("identity: set control deadline: %w", err)
	}
	nonceBytes := make([]byte, identNonceBytes)
	if _, err := rand.Read(nonceBytes); err != nil {
		return nil, fmt.Errorf("identity: generate request nonce: %w", err)
	}
	nonce := hex.EncodeToString(nonceBytes)
	if _, err := io.WriteString(conn, "IDENT "+secret+" "+nonce+"\n"); err != nil {
		return nil, fmt.Errorf("identity: write request: %w", err)
	}

	line, err := bufio.NewReader(io.LimitReader(conn, maxIdentReplyBytes+1)).ReadString('\n')
	if errors.Is(err, io.EOF) && len(line) == 0 {
		return nil, ErrIdentRefused
	}
	if err != nil {
		return nil, fmt.Errorf("identity: read reply: %w", err)
	}
	if len(line) > maxIdentReplyBytes {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Pass a positive timeout to Identify
  2. Check for clock skew if system time is unreliable
  3. Report as a bug if it occurs with a valid positive timeout

Example fix

// before
Identify(host, port, secret, 0)
// after
Identify(host, port, secret, 5*time.Second)
Defensive patterns

Strategy: validation

Validate before calling

if timeout <= 0 {
	return errors.New("Identify requires a positive timeout")
}

Try / catch

if err != nil && strings.Contains(err.Error(), "set control deadline") {
	// fix timeout value and retry once
}

Prevention

When it happens

Trigger: conn.SetDeadline returning an error right after a successful dial — typically a zero/negative-time deadline from a zero time.Duration making time.Now().Add(timeout) land before now, or an exotic conn in a broken state.

Common situations: Passing timeout of 0 or negative, producing a deadline already in the past on some platforms; highly unusual otherwise.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/97fc1f10370c0c6d. Report an issue: GitHub.