Skip to content

Commit

Permalink
fix(graphql): resolve duplicate events on socket reconnect
Browse files Browse the repository at this point in the history
Resolved an issue in WebSocketClient where multiple listeners were added to `waitForConnectedState` when socket reconnects after subscription been requtesed with disconnected socket, causing duplicate events to be received by subscriptions.
  • Loading branch information
aarsham committed Apr 8, 2024
1 parent 1003c4b commit be11b4c
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ class SocketClient {
)
: waitForConnectedStateWithoutTimeout;

sub?.cancel();
sub = waitForConnectedState.listen((_) {
final Stream<GraphQLSocketMessage> dataErrorComplete = _messages.where(
(GraphQLSocketMessage message) {
Expand Down

0 comments on commit be11b4c

Please # to comment.