Skip to content

[bug] Close leaks the gRPC connection because we never retain or close it #84

@Unique-Divine

Description

@Unique-Divine

⚠️ Potential issue | 🟠 Major

Close leaks the gRPC connection because we never retain or close it

DialPricePoster creates a client connection but drops the handle, and Close() is a no-op. The pricefeeder’s shutdown hooks expect this to release network resources. Store the *grpc.ClientConn and close it (logging on error) during Close().

 type deps struct {
 	oracleClient Oracle
 	authClient   Auth
 	txClient     TxService
 	keyBase      keyring.Keyring
 	txConfig     client.TxConfig
 	ir           codectypes.InterfaceRegistry
 	chainID      string
+	conn         *grpc.ClientConn
 }
@@
 	deps := deps{
+		conn:         conn,
 		oracleClient: oracletypes.NewQueryClient(conn),
 		authClient:   authtypes.NewQueryClient(conn),
 		txClient:     txservice.NewServiceClient(conn),
@@
 func (c *ClientPricePoster) Close() {
+	if c.deps.conn != nil {
+		if err := c.deps.conn.Close(); err != nil {
+			c.logger.Err(err).Msg("failed to close price poster connection")
+		}
+	}
 }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In feeder/priceposter.go around lines 101 to 145, the Close method currently
does nothing while DialPricePoster creates a gRPC client connection and drops
the handle, leaking the network resource; modify the ClientPricePoster struct to
hold a *grpc.ClientConn field, update DialPricePoster to assign the created
connection to that field instead of discarding it, and implement Close() to
check for a non-nil conn, call conn.Close(), and log any returned error via
c.logger (and return/ignore the error per existing Close signature), ensuring
nil-safe behavior so the connection is released on shutdown.

Originally posted by @coderabbitai[bot] in #81 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-triageStatus: This issue is waiting on initial triage. More Info: https://tinyurl.com/25uty9w5

    Type

    No type

    Projects

    Status

    ⚡ Building 🧱

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions