celestiaorg / celestiaorg/celestia-node
api/rpc/client: Close namespace connections
- Dominant language
- Go
- Stars
- 996
- Forks
- 1.1k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 34
Description
### Problem
`api/rpc/client.newClient` opens one JSON-RPC client per namespace. It records each returned `ClientCloser` in a local `multiClientCloser`, but that value is discarded when `newClient` returns. As a result, `Client.Close()` does not close anything.
For `ws` and `wss` clients this leaves one WebSocket connection and its client goroutine alive per namespace until the parent context is canceled. If a later namespace fails to initialize, connections opened for earlier namespaces are also left running.
### Expected behavior
The client should own all namespace closers, roll back connections opened during partial initialization, and allow `Close` to be called more than once without panicking.
Contributor guide
Research direction
Start at api/rpc/client.newClient and trace how multiClientCloser and each ClientCloser are stored, then inspect Client.Close for ws and wss lifecycle handling. Done means the returned client owns every namespace closer, partial initialization closes earlier connections, and repeated Close calls do not panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100