Skip to content

Commit

Permalink
fix panic (gagliardetto#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdsxg authored and mhughdo committed Jul 7, 2024
1 parent 43ed33b commit 5d499d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rpc/ws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ func (c *Client) handleSubscriptionMessage(subID uint64, message []byte) {
return
}

sub.stream <- result
if !sub.closed {
sub.stream <- result
}
return
}

Expand Down
2 changes: 2 additions & 0 deletions rpc/ws/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Subscription struct {
stream chan result
err chan error
closeFunc func(err error)
closed bool
unsubscribeMethod string
decoderFunc decoderFunc
}
Expand Down Expand Up @@ -61,6 +62,7 @@ func (s *Subscription) Unsubscribe() {

func (s *Subscription) unsubscribe(err error) {
s.closeFunc(err)
s.closed = true
close(s.stream)
close(s.err)
}

0 comments on commit 5d499d3

Please sign in to comment.