Skip to content

Commit

Permalink
Ignore context.Canceled errors when marking a peer as active (#195)
Browse files Browse the repository at this point in the history
It just means the connection was closed the same time we tried to mark
the peer as active.
  • Loading branch information
erikdubbelboer authored Feb 9, 2025
1 parent b30f502 commit 7110d2a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/signaling/timeout_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package signaling
import (
"context"
"encoding/json"
"errors"
"time"

"github.com/koenbollen/logging"
Expand Down Expand Up @@ -117,7 +118,10 @@ func (manager *TimeoutManager) MarkPeerAsActive(ctx context.Context, peerID stri
logger := logging.GetLogger(ctx)

err := manager.Store.MarkPeerAsActive(ctx, peerID)
if err != nil {

// context.Canceled is expected when the connection is closed right as this function
// is called. We don't want to log this as an error.
if err != nil && !errors.Is(err, context.Canceled) {
logger.Error("failed to mark peer as active", zap.Error(err), zap.String("peer", peerID))
}
}
Expand Down

0 comments on commit 7110d2a

Please sign in to comment.