{"record":{"id":"97fc1f10370c0c6d","repo":"gastownhall/beads","slug":"identity-set-control-deadline-w","errorCode":null,"errorMessage":"identity: set control deadline: %w","messagePattern":"identity: set control deadline: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/identity/control.go","lineNumber":50,"sourceCode":"\tUpstreamID  string `json:\"upstream_id\"`\n\tPID         int    `json:\"pid\"`\n\tBirth       string `json:\"birth\"`\n\tDataPort    int    `json:\"data_port\"`\n\tControlPort int    `json:\"control_port\"`\n\tMAC         string `json:\"mac\"`\n}\n\n// Identify authenticates to a proxy control listener and returns its identity.\nfunc Identify(host string, controlPort int, secret string, timeout time.Duration) (*IdentReply, error) {\n\taddr := net.JoinHostPort(host, strconv.Itoa(controlPort))\n\tconn, err := net.DialTimeout(\"tcp\", addr, timeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"identity: dial control listener: %w\", err)\n\t}\n\tdefer func() { _ = conn.Close() }()\n\n\tif err := conn.SetDeadline(time.Now().Add(timeout)); err != nil {\n\t\treturn nil, fmt.Errorf(\"identity: set control deadline: %w\", err)\n\t}\n\tnonceBytes := make([]byte, identNonceBytes)\n\tif _, err := rand.Read(nonceBytes); err != nil {\n\t\treturn nil, fmt.Errorf(\"identity: generate request nonce: %w\", err)\n\t}\n\tnonce := hex.EncodeToString(nonceBytes)\n\tif _, err := io.WriteString(conn, \"IDENT \"+secret+\" \"+nonce+\"\\n\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"identity: write request: %w\", err)\n\t}\n\n\tline, err := bufio.NewReader(io.LimitReader(conn, maxIdentReplyBytes+1)).ReadString('\\n')\n\tif errors.Is(err, io.EOF) && len(line) == 0 {\n\t\treturn nil, ErrIdentRefused\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"identity: read reply: %w\", err)\n\t}\n\tif len(line) > maxIdentReplyBytes {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/identity/control.go#L32-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"Passing timeout of 0 or negative, producing a deadline already in the past on some platforms; highly unusual otherwise.","solutions":["Pass a positive timeout to Identify","Check for clock skew if system time is unreliable","Report as a bug if it occurs with a valid positive timeout"],"exampleFix":"// before\nIdentify(host, port, secret, 0)\n// after\nIdentify(host, port, secret, 5*time.Second)","handlingStrategy":"validation","validationCode":"if timeout <= 0 {\n\treturn errors.New(\"Identify requires a positive timeout\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"set control deadline\") {\n\t// fix timeout value and retry once\n}","preventionTips":["Always pass a positive, sane timeout (seconds, not zero/negative)","Check host clock settings if deadlines behave oddly","Escalate to a bug report if seen with a valid timeout"],"tags":["network","timeout","deadline","dbproxy"],"backgroundTag":"deadline-set-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}