diff --git a/CHANGELOG.md b/CHANGELOG.md index f6ef4566a1..ad5a014376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Changelog for NeoFS Node - ObjectID signature output in the CLI (#2104) - Pack arguments of `setPrice` invocation during contract update (#2078) - `neofs-cli object hash` panic (#2079) +- Closing `neo-go` WS clients on shutdown and switch processes (#2080) ### Removed - `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089) diff --git a/cmd/neofs-node/morph.go b/cmd/neofs-node/morph.go index 4ceee9e3f7..21db514f37 100644 --- a/cmd/neofs-node/morph.go +++ b/cmd/neofs-node/morph.go @@ -62,6 +62,8 @@ func initMorphComponents(c *cfg) { fatalOnErr(err) } + c.onShutdown(cli.Close) + if err := cli.SetGroupSignerScope(); err != nil { c.log.Info("failed to set group signer scope, continue with Global", zap.Error(err)) } diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 958af33202..7096511bcd 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -153,6 +153,12 @@ func (c *Client) newCli(endpoint string) (*rpcclient.WSClient, *actor.Actor, err return nil, nil, fmt.Errorf("WS client creation: %w", err) } + defer func() { + if err != nil { + cli.Close() + } + }() + err = cli.Init() if err != nil { return nil, nil, fmt.Errorf("WS client initialization: %w", err)