graphql-flutter icon indicating copy to clipboard operation
graphql-flutter copied to clipboard

Subscription will receive same event in some edge case

Open stardarLeung opened this issue 3 years ago • 0 comments

Describe the issue version: 5.0.0+1 lib/src/links/websocket_link/websocket_client.dart at line 365 sub = waitForConnectedState.listen...... at line 241 if (_connectionWasLost) { for (final s in _subscriptionInitializers.values) { s.callback(); // (onListen()) } _connectionWasLost = false; } If socket disconnected when fetch subscribe,onListen will trigger again so that waitForConnectedState will have two or more listener. When socket reconnected, two or more listener will do something same cause subscription receive same event from socket. My solution is cancel listener like sub?.cancel() after add listener to waitForConnectedState.

stardarLeung avatar Dec 01 '21 10:12 stardarLeung