{"record":{"id":"d89c5cc4ace80fdc","repo":"ginuerzh/gost","slug":"deadline-not-supported-d89c5c","errorCode":null,"errorMessage":"deadline not supported","messagePattern":"deadline not supported","errorType":"exception","errorClass":"net.OpError","httpStatus":null,"severity":"warning","filePath":"ssh.go","lineNumber":932,"sourceCode":"\treturn nil\n}\n\nfunc (c *sshNopConn) LocalAddr() net.Addr {\n\treturn &net.TCPAddr{\n\t\tIP:   net.IPv4zero,\n\t\tPort: 0,\n\t}\n}\n\nfunc (c *sshNopConn) RemoteAddr() net.Addr {\n\treturn &net.TCPAddr{\n\t\tIP:   net.IPv4zero,\n\t\tPort: 0,\n\t}\n}\n\nfunc (c *sshNopConn) SetDeadline(t time.Time) error {\n\treturn &net.OpError{Op: \"set\", Net: \"ssh\", Source: nil, Addr: nil, Err: errors.New(\"deadline not supported\")}\n}\n\nfunc (c *sshNopConn) SetReadDeadline(t time.Time) error {\n\treturn &net.OpError{Op: \"set\", Net: \"ssh\", Source: nil, Addr: nil, Err: errors.New(\"deadline not supported\")}\n}\n\nfunc (c *sshNopConn) SetWriteDeadline(t time.Time) error {\n\treturn &net.OpError{Op: \"set\", Net: \"ssh\", Source: nil, Addr: nil, Err: errors.New(\"deadline not supported\")}\n}\n\ntype sshConn struct {\n\tchannel ssh.Channel\n\tconn    net.Conn\n}\n\nfunc (c *sshConn) Read(b []byte) (n int, err error) {\n\treturn c.channel.Read(b)\n}","sourceCodeStart":914,"sourceCodeEnd":950,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/ssh.go#L914-L950","documentation":"sshNopConn does not support deadlines: SetDeadline returns a *net.OpError (Op \"set\", Net \"ssh\") wrapping \"deadline not supported\". This stub exists because the nop conn has no real socket to arm; it signals that deadline-based timeout control is unavailable on this connection.","triggerScenarios":"Calling SetDeadline on a *sshNopConn, typically via a net.Conn-consumer that unconditionally sets deadlines before I/O (HTTP transports, deadline-wrapping helpers, net.Conn middleware).","commonSituations":"Wrapping the nop conn in a timeout container (e.g. a conn that enforces read/write deadlines); libraries that set deadlines as part of handshake or keepalive logic.","solutions":["Skip deadline setting when the conn is a sshNopConn (type-check or feature-detect before calling SetDeadline)","Apply timeouts at a higher level (context.WithTimeout around the operation) instead of conn deadlines","Swap the nop conn for the deadline-capable sshConn/underlying net.Conn if deadline enforcement is required"],"exampleFix":"// before\nconn.SetDeadline(time.Now().Add(5*time.Second)) // panics into error on nop conn\n// after\nctx, cancel := context.WithTimeout(ctx, 5*time.Second)\ndefer cancel()\n// do the operation with ctx","handlingStrategy":"fallback","validationCode":"func supportsDeadlines(c net.Conn) bool {\n    _, nop := c.(*sshNopConn)\n    return !nop\n}","typeGuard":"func withDeadline(c net.Conn, t time.Time) error {\n    if _, nop := c.(*sshNopConn); nop { return nil } // skip, use context timeout instead\n    return c.SetDeadline(t)\n}","tryCatchPattern":"if err := conn.SetDeadline(time.Now().Add(5*time.Second)); err != nil {\n    var opErr *net.OpError\n    if errors.As(err, &opErr) && opErr.Net == \"ssh\" {\n        // fall back to context-based timeout\n        ctx, cancel = context.WithTimeout(ctx, 5*time.Second)\n        defer cancel()\n    } else { return err }\n}","preventionTips":["Prefer context.WithTimeout over conn deadlines for ssh-backed conns","Feature-detect deadline support before calling Set*Deadline","Keep a single helper that safely applies deadlines only where supported"],"tags":["ssh","net-op-error","deadline","unsupported-operation"],"backgroundTag":"deadline-not-supported","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}