{"record":{"id":"fafa347182edaedd","repo":"nats-io/nats-server","slug":"failed-to-clear-deadline-v","errorCode":null,"errorMessage":"failed to clear deadline: %v","messagePattern":"failed to clear deadline: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/leafnode.go","lineNumber":676,"sourceCode":"\tresp, err := http.ReadResponse(bufio.NewReader(conn), req)\n\tif err != nil {\n\t\tconn.Close()\n\t\treturn nil, fmt.Errorf(\"failed to read proxy response: %v\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tresp.Body.Close()\n\t\tconn.Close()\n\t\treturn nil, fmt.Errorf(\"proxy CONNECT failed: %s\", resp.Status)\n\t}\n\n\t// Close the response body\n\tresp.Body.Close()\n\n\t// Clear the deadline now that we've finished the proxy handshake\n\tif err := conn.SetDeadline(time.Time{}); err != nil {\n\t\tconn.Close()\n\t\treturn nil, fmt.Errorf(\"failed to clear deadline: %v\", err)\n\t}\n\n\treturn conn, nil\n}\n\n// Connect to a remote leaf node asynchronously (that is, this function will do\n// the connect in a go routine).\nfunc (s *Server) connectToRemoteLeafNodeAsynchronously(remote *leafNodeCfg, firstConnect bool) {\n\tremote.setConnectInProgress(true)\n\ts.startGoRoutine(func() {\n\t\tdefer s.grWG.Done()\n\t\tif !connectToRemoteLeafNode(s, remote, firstConnect) {\n\t\t\tremote.setConnectInProgress(false)\n\t\t}\n\t})\n}\n\n// Connect to a remote leaf node. Should only be invoked from","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/leafnode.go#L658-L694","documentation":"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.","triggerScenarios":"Thrown at server/leafnode.go:676 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}