Skip to content

Commit

Permalink
fix panic
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdsxg committed Jun 6, 2024
1 parent a5e17d6 commit ed51979
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 @@ -246,7 +246,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 ed51979

Please sign in to comment.