diff --git a/packages/graphql/lib/src/links/websocket_link/websocket_client.dart b/packages/graphql/lib/src/links/websocket_link/websocket_client.dart index 6d2f8c881..a6a6aacd1 100644 --- a/packages/graphql/lib/src/links/websocket_link/websocket_client.dart +++ b/packages/graphql/lib/src/links/websocket_link/websocket_client.dart @@ -495,7 +495,19 @@ class SocketClient { .where((message) => message is SubscriptionComplete) .take(1); - subscriptionComplete.listen((_) => response.close()); + subscriptionComplete.listen( + (_) => response.close(), + onDone: () { + if (!config.autoReconnect) { + response.close(); + } + }, + onError: (_) { + if (!config.autoReconnect) { + response.close(); + } + }, + ); dataErrorComplete .where((message) => message is SubscriptionData)