Skip to content

Commit

Permalink
fix(rpc): fix websocket subscription panic when no closing error (#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
srene authored Aug 27, 2024
1 parent fe0f3cb commit 6bf24d0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions rpc/json/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

"github.com/gorilla/websocket"

tmpubsub "github.com/tendermint/tendermint/libs/pubsub"

"github.com/dymensionxyz/dymint/types"
Expand Down Expand Up @@ -79,13 +78,13 @@ func (h *handler) wsHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
if _, ok := err.(*websocket.CloseError); ok {
h.logger.Debug("WebSocket connection closed", "reason", err)
err := h.srv.client.EventBus.UnsubscribeAll(r.Context(), remoteAddr)
if err != nil && !errors.Is(err, tmpubsub.ErrSubscriptionNotFound) {
h.logger.Error("unsubscribe addr from events", "addr", remoteAddr, "err", err)
}
} else {
h.logger.Error("read next WebSocket message", "error", err)
}
err := h.srv.client.EventBus.UnsubscribeAll(r.Context(), remoteAddr)
if err != nil && !errors.Is(err, tmpubsub.ErrSubscriptionNotFound) {
h.logger.Error("unsubscribe addr from events", "addr", remoteAddr, "err", err)
}
break
}

Expand Down

0 comments on commit 6bf24d0

Please sign in to comment.