Skip to content

Commit

Permalink
node: syncer panic send on closed channel (#2366)
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-vk authored Feb 13, 2025
1 parent 8524dde commit 1beac1b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/node/rpc/sync/client/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"context"

"github.com/ethereum/go-ethereum/common"
"github.com/linkdata/deadlock"
. "github.com/towns-protocol/towns/core/node/base"
Expand Down
1 change: 0 additions & 1 deletion core/node/rpc/sync/client/syncer_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func (ss *SyncerSet) Run() {
ss.muSyncers.Unlock()

ss.syncerTasks.Wait() // background syncers finished -> safe to close messages channel
close(ss.messages) // close will cause the sync operation to send the SYNC_CLOSE message to the client
}

func (ss *SyncerSet) AddInitialStreams() {
Expand Down
6 changes: 5 additions & 1 deletion core/node/rpc/sync/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ func (syncOp *StreamSyncOperation) Run(
) error {
log := logging.FromCtx(syncOp.ctx).With("syncId", syncOp.SyncID)

messagesSendToClient := 0

log.Info("Stream sync operation start")
defer log.Info("Stream sync operation stopped")
defer log.Infow("Stream sync operation stopped", "send", messagesSendToClient)

cookies, err := client.ValidateAndGroupSyncCookies(req.Msg.GetSyncPos())
if err != nil {
Expand Down Expand Up @@ -131,6 +133,8 @@ func (syncOp *StreamSyncOperation) Run(
return err
}

messagesSendToClient++

log.Debug("Pending messages in sync operation", "count", len(messages))

case <-syncOp.ctx.Done():
Expand Down

0 comments on commit 1beac1b

Please sign in to comment.