nats-io/nats-server · error
failed to clear deadline: %v
Error message
failed to clear deadline: %v
What it means
HTTP proxy tunnel setup: after a successful CONNECT handshake, clearing the previously set deadline via conn.SetDeadline(time.Time{}) failed, indicating the connection is already in a bad state, so it is closed and the error surfaced.
Source
Thrown at server/leafnode.go:676
resp, err := http.ReadResponse(bufio.NewReader(conn), req)
if err != nil {
conn.Close()
return nil, fmt.Errorf("failed to read proxy response: %v", err)
}
if resp.StatusCode != http.StatusOK {
resp.Body.Close()
conn.Close()
return nil, fmt.Errorf("proxy CONNECT failed: %s", resp.Status)
}
// Close the response body
resp.Body.Close()
// Clear the deadline now that we've finished the proxy handshake
if err := conn.SetDeadline(time.Time{}); err != nil {
conn.Close()
return nil, fmt.Errorf("failed to clear deadline: %v", err)
}
return conn, nil
}
// Connect to a remote leaf node asynchronously (that is, this function will do
// the connect in a go routine).
func (s *Server) connectToRemoteLeafNodeAsynchronously(remote *leafNodeCfg, firstConnect bool) {
remote.setConnectInProgress(true)
s.startGoRoutine(func() {
defer s.grWG.Done()
if !connectToRemoteLeafNode(s, remote, firstConnect) {
remote.setConnectInProgress(false)
}
})
}
// Connect to a remote leaf node. Should only be invoked fromView on GitHub (pinned to 3a66a489d2)
Solutions
- Treat as a fatal connection failure and let reconnect logic retry with a fresh connection
- Check whether the proxy or intermediate is closing connections early
- Verify no concurrent close of the same conn
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at server/leafnode.go:676 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/fafa347182edaedd.
Report an issue: GitHub.