Skip to content

Commit

Permalink
Don't call ErrorAndDisconnect in a goroutine
Browse files Browse the repository at this point in the history
ErrorAndDisconnect can only be called in a handler as it panics with
http.ErrAbortHandler which normally gets recovered by net/http.
  • Loading branch information
erikdubbelboer committed Sep 11, 2023
1 parent 4a4b93a commit a19e721
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/signaling/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func Handler(ctx context.Context, store stores.Store, cloudflare *cloudflare.Cre
for {
select {
case <-ticker.C:
if err := peer.Send(ctx, PingPacket{Type: "ping"}); err != nil {
util.ErrorAndDisconnect(ctx, conn, err)
if err := peer.Send(ctx, PingPacket{Type: "ping"}); err != nil && !util.IsPipeError(err) {
logger.Error("failed to send ping packet", zap.String("peer", peer.ID), zap.Error(err))
}
case <-ctx.Done():
return
Expand Down

0 comments on commit a19e721

Please sign in to comment.