fix_: add missing defer LogOnPanic

This commit is contained in:
Igor Sirotin 2024-10-22 16:31:43 +01:00
parent a1e77e91df
commit 88b744960b
No known key found for this signature in database
GPG Key ID: 425E227CAAB81F95
12 changed files with 36 additions and 7 deletions

View File

@ -81,7 +81,7 @@ func start(p StartParams, logger *zap.SugaredLogger) (*StatusCLI, error) {
} }
waku := backend.StatusNode().WakuV2Service() waku := backend.StatusNode().WakuV2Service()
telemetryClient := telemetry.NewClient(telemetryLogger, p.TelemetryURL, backend.SelectedAccountKeyID(), p.Name, "cli", telemetry.WithPeerID(waku.PeerID().String())) telemetryClient := telemetry.NewClient(telemetryLogger, p.TelemetryURL, backend.SelectedAccountKeyID(), p.Name, "cli", telemetry.WithPeerID(waku.PeerID().String()))
go telemetryClient.Start(context.Background()) telemetryClient.Start(context.Background())
backend.StatusNode().WakuV2Service().SetStatusTelemetryClient(telemetryClient) backend.StatusNode().WakuV2Service().SetStatusTelemetryClient(telemetryClient)
} }
wakuAPI := wakuv2ext.NewPublicAPI(wakuService) wakuAPI := wakuv2ext.NewPublicAPI(wakuService)

View File

@ -6,6 +6,7 @@ import (
"github.com/status-im/status-go/healthmanager/aggregator" "github.com/status-im/status-go/healthmanager/aggregator"
"github.com/status-im/status-go/healthmanager/rpcstatus" "github.com/status-im/status-go/healthmanager/rpcstatus"
gocommon "github.com/status-im/status-go/common"
) )
// BlockchainFullStatus contains the full status of the blockchain, including provider statuses. // BlockchainFullStatus contains the full status of the blockchain, including provider statuses.
@ -72,6 +73,7 @@ func (b *BlockchainHealthManager) RegisterProvidersHealthManager(ctx context.Con
statusCh := phm.Subscribe() statusCh := phm.Subscribe()
b.wg.Add(1) b.wg.Add(1)
go func(phm *ProvidersHealthManager, statusCh chan struct{}, providerCtx context.Context) { go func(phm *ProvidersHealthManager, statusCh chan struct{}, providerCtx context.Context) {
defer gocommon.LogOnPanic()
defer func() { defer func() {
phm.Unsubscribe(statusCh) phm.Unsubscribe(statusCh)
b.wg.Done() b.wg.Done()

View File

@ -11,6 +11,7 @@ import (
prom "github.com/prometheus/client_golang/prometheus" prom "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/status-im/status-go/common"
) )
// Server runs and controls a HTTP pprof interface. // Server runs and controls a HTTP pprof interface.
@ -55,5 +56,6 @@ func Handler(reg metrics.Registry) http.Handler {
// Listen starts the HTTP server in the background. // Listen starts the HTTP server in the background.
func (p *Server) Listen() { func (p *Server) Listen() {
defer common.LogOnPanic()
log.Info("metrics server stopped", "err", p.server.ListenAndServe()) log.Info("metrics server stopped", "err", p.server.ListenAndServe())
} }

View File

@ -73,6 +73,7 @@ func (p *Publisher) Stop() {
} }
func (p *Publisher) tickerLoop() { func (p *Publisher) tickerLoop() {
defer gocommon.LogOnPanic()
ticker := time.NewTicker(tickerInterval * time.Second) ticker := time.NewTicker(tickerInterval * time.Second)
go func() { go func() {

View File

@ -581,7 +581,7 @@ func NewMessenger(
if c.wakuService != nil { if c.wakuService != nil {
c.wakuService.SetStatusTelemetryClient(telemetryClient) c.wakuService.SetStatusTelemetryClient(telemetryClient)
} }
go telemetryClient.Start(ctx) telemetryClient.Start(ctx)
} }
messenger = &Messenger{ messenger = &Messenger{
@ -916,7 +916,7 @@ func (m *Messenger) Start() (*MessengerResponse, error) {
for _, c := range controlledCommunities { for _, c := range controlledCommunities {
if c.Joined() && c.HasTokenPermissions() { if c.Joined() && c.HasTokenPermissions() {
go m.communitiesManager.StartMembersReevaluationLoop(c.ID(), false) m.communitiesManager.StartMembersReevaluationLoop(c.ID(), false)
} }
} }

View File

@ -500,6 +500,8 @@ func (r *storeNodeRequest) shouldFetchNextPage(envelopesCount int) (bool, uint32
} }
func (r *storeNodeRequest) routine() { func (r *storeNodeRequest) routine() {
defer gocommon.LogOnPanic()
r.manager.logger.Info("starting store node request", r.manager.logger.Info("starting store node request",
zap.Any("requestID", r.requestID), zap.Any("requestID", r.requestID),
zap.String("pubsubTopic", r.pubsubTopic), zap.String("pubsubTopic", r.pubsubTopic),

View File

@ -188,6 +188,7 @@ func (c *Client) Stop() {
} }
func (c *Client) monitorHealth(ctx context.Context, statusCh chan struct{}) { func (c *Client) monitorHealth(ctx context.Context, statusCh chan struct{}) {
defer appCommon.LogOnPanic()
sendFullStatusEventFunc := func() { sendFullStatusEventFunc := func() {
blockchainStatus := c.healthMgr.GetFullStatus() blockchainStatus := c.healthMgr.GetFullStatus()
encodedMessage, err := json.Marshal(blockchainStatus) encodedMessage, err := json.Marshal(blockchainStatus)

View File

@ -42,6 +42,7 @@ import (
"github.com/status-im/status-go/services/wallet/walletconnect" "github.com/status-im/status-go/services/wallet/walletconnect"
"github.com/status-im/status-go/signal" "github.com/status-im/status-go/signal"
"github.com/status-im/status-go/transactions" "github.com/status-im/status-go/transactions"
common2 "github.com/status-im/status-go/common"
) )
func NewAPI(s *Service) *API { func NewAPI(s *Service) *API {
@ -779,6 +780,7 @@ func (api *API) BuildTransactionsFromRoute(ctx context.Context, buildInputParams
log.Debug("[WalletAPI::BuildTransactionsFromRoute] builds transactions from the generated best route", "uuid", buildInputParams.Uuid) log.Debug("[WalletAPI::BuildTransactionsFromRoute] builds transactions from the generated best route", "uuid", buildInputParams.Uuid)
go func() { go func() {
defer common2.LogOnPanic()
api.router.StopSuggestedRoutesAsyncCalculation() api.router.StopSuggestedRoutesAsyncCalculation()
var err error var err error
@ -841,6 +843,7 @@ func (api *API) ProceedWithTransactionsSignatures(ctx context.Context, signature
func (api *API) SendRouterTransactionsWithSignatures(ctx context.Context, sendInputParams *requests.RouterSendTransactionsParams) { func (api *API) SendRouterTransactionsWithSignatures(ctx context.Context, sendInputParams *requests.RouterSendTransactionsParams) {
log.Debug("[WalletAPI:: SendRouterTransactionsWithSignatures] sign with signatures and send") log.Debug("[WalletAPI:: SendRouterTransactionsWithSignatures] sign with signatures and send")
go func() { go func() {
defer common2.LogOnPanic()
var ( var (
err error err error
@ -927,6 +930,7 @@ func (api *API) SendRouterTransactionsWithSignatures(ctx context.Context, sendIn
chainIDs = append(chainIDs, tx.FromChain) chainIDs = append(chainIDs, tx.FromChain)
addresses = append(addresses, common.Address(tx.FromAddress)) addresses = append(addresses, common.Address(tx.FromAddress))
go func(chainId uint64, txHash common.Hash) { go func(chainId uint64, txHash common.Hash) {
defer common2.LogOnPanic()
err = api.s.transactionManager.WatchTransaction(context.Background(), chainId, txHash) err = api.s.transactionManager.WatchTransaction(context.Background(), chainId, txHash)
if err != nil { if err != nil {
return return

View File

@ -8,6 +8,7 @@ import (
"github.com/jellydator/ttlcache/v3" "github.com/jellydator/ttlcache/v3"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/common"
) )
var ( var (
@ -56,7 +57,10 @@ func (c *ttlCache[K, V]) init() {
c.cache.OnEviction(func(ctx context.Context, reason ttlcache.EvictionReason, item *ttlcache.Item[K, V]) { c.cache.OnEviction(func(ctx context.Context, reason ttlcache.EvictionReason, item *ttlcache.Item[K, V]) {
log.Debug("Evicting item from balance/nonce cache", "reason", reason, "key", item.Key, "value", item.Value) log.Debug("Evicting item from balance/nonce cache", "reason", reason, "key", item.Key, "value", item.Value)
}) })
go c.cache.Start() // starts automatic expired item deletion go func() { // starts automatic expired item deletion
defer common.LogOnPanic()
c.cache.Start()
}()
} }
//nolint:golint,unused // linter does not detect using it via reflect //nolint:golint,unused // linter does not detect using it via reflect

View File

@ -5,6 +5,7 @@ import (
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/status-im/status-go/services/wallet/walletevent" "github.com/status-im/status-go/services/wallet/walletevent"
"github.com/status-im/status-go/common"
) )
type FeedSubscription struct { type FeedSubscription struct {
@ -20,6 +21,7 @@ func NewFeedSubscription(feed *event.Feed) *FeedSubscription {
subscription := feed.Subscribe(events) subscription := feed.Subscribe(events)
go func() { go func() {
defer common.LogOnPanic()
<-done <-done
subscription.Unsubscribe() subscription.Unsubscribe()
close(events) close(events)

View File

@ -481,6 +481,8 @@ func (p *Peer) handshake() error {
// update executes periodic operations on the peer, including message transmission // update executes periodic operations on the peer, including message transmission
// and expiration. // and expiration.
func (p *Peer) update() { func (p *Peer) update() {
defer gocommon.LogOnPanic()
// Start the tickers for the updates // Start the tickers for the updates
expire := time.NewTicker(common.ExpirationCycle) expire := time.NewTicker(common.ExpirationCycle)
transmit := time.NewTicker(common.TransmissionCycle) transmit := time.NewTicker(common.TransmissionCycle)

View File

@ -196,7 +196,10 @@ func (w *Waku) SetStatusTelemetryClient(client ITelemetryClient) {
func newTTLCache() *ttlcache.Cache[gethcommon.Hash, *common.ReceivedMessage] { func newTTLCache() *ttlcache.Cache[gethcommon.Hash, *common.ReceivedMessage] {
cache := ttlcache.New[gethcommon.Hash, *common.ReceivedMessage](ttlcache.WithTTL[gethcommon.Hash, *common.ReceivedMessage](cacheTTL)) cache := ttlcache.New[gethcommon.Hash, *common.ReceivedMessage](ttlcache.WithTTL[gethcommon.Hash, *common.ReceivedMessage](cacheTTL))
go cache.Start() go func() {
defer gocommon.LogOnPanic()
cache.Start()
}()
return cache return cache
} }
@ -1219,7 +1222,10 @@ func (w *Waku) Start() error {
w.wg.Add(1) w.wg.Add(1)
go w.broadcast() go w.broadcast()
go w.sendQueue.Start(w.ctx) go func() {
defer gocommon.LogOnPanic()
w.sendQueue.Start(w.ctx)
}()
err = w.startMessageSender() err = w.startMessageSender()
if err != nil { if err != nil {
@ -1718,7 +1724,10 @@ func (w *Waku) ConnectionChanged(state connection.State) {
isOnline := !state.Offline isOnline := !state.Offline
if w.cfg.LightClient { if w.cfg.LightClient {
//TODO: Update this as per https://github.com/waku-org/go-waku/issues/1114 //TODO: Update this as per https://github.com/waku-org/go-waku/issues/1114
go w.filterManager.OnConnectionStatusChange("", isOnline) go func() {
defer gocommon.LogOnPanic()
w.filterManager.OnConnectionStatusChange("", isOnline)
}()
w.handleNetworkChangeFromApp(state) w.handleNetworkChangeFromApp(state)
} else { } else {
// for lightClient state update and onlineChange is handled in filterManager. // for lightClient state update and onlineChange is handled in filterManager.