zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 620 forks source link

ws: Unhandled exceptions from SocketClient #1270

Open etegan opened 1 year ago

etegan commented 1 year ago

Describe the issue The SocketClient._connect() function sets up a bunch of StreamSubscriptions on _messages that don't have any onError callbacks. For example #1228 will result in multiple unhandled exceptions that can't be caught by the user of this package.

To Reproduce

  1. Make GraphQLSocketMessage.parse throw any exception
  2. Try to catch it from any application that tries to create a ws connection
  3. observe the mayhem
  4. (optional) Change Stream<GraphQLSocketMessage> get _messages => socketChannel!.messages; in SocketClient to Stream<GraphQLSocketMessage> get _messages => socketChannel!.messages.handleError((e) => print("Getting errors ${e}"))

Expected behavior Exceptions from SocketClient should not escape _connect() or the user should be able to catch them.

vincenzopalazzo commented 1 year ago

You are right, there is some work to do to modify the error handling!

Thanks to report it