mfeckie / phoenix_wings

Phoenix Channels client for Dart / Flutter
MIT License
163 stars 48 forks source link

Unhandled Exception #29

Closed Quantum-Sicarius closed 3 years ago

Quantum-Sicarius commented 3 years ago

Hello, I have encountered an Unhandled Exception

Log from ADB:

E/flutter (13139): #0      PhoenixSocket._onConnMessage.<anonymous closure> (package:phoenix_wings/src/phoenix_socket.dart:165:37)
E/flutter (13139): #1      WhereIterator.moveNext (dart:_internal/iterable.dart:437:13)
E/flutter (13139): #2      Iterable.forEach (dart:core/iterable.dart:257:23)
E/flutter (13139): #3      PhoenixSocket._onConnMessage (package:phoenix_wings/src/phoenix_socket.dart:167:10)
E/flutter (13139): #4      PhoenixIoConnection.onMessage.<anonymous closure> (package:phoenix_wings/src/phoenix_io_connection.dart:67:15)
E/flutter (13139): #5      _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (13139): #6      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (13139): #7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (13139): #8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (13139): #9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (13139): #10     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
E/flutter (13139): #11     _StreamController._add (dart:async/stream_controller.dart:607:7)
E/flutter (13139): #12     _StreamController.add (dart:async/stream_controller.dart:554:5)
E/flutter (13139): #13     new _WebSocketImpl._fromSocket.<anonymous closure> (dart:_http/websocket_impl.dart:1145:21)
E/flutter (13139): #14     _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (13139): #15     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (13139): #16     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (13139): #17     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (13139): #18     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (13139): #19     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
E/flutter (13139): #20     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
E/flutter (13139): #21     _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:338:23)
E/flutter (13139): #22     _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:232:46)
E/flutter (13139): #23     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
E/flutter (13139): #24     _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (13139): #25     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (13139): #26     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (13139): #27     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (13139): #28     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (13139): #29     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
E/flutter (13139): #30     _StreamController._add (dart:async/stream_controller.dart:607:7)
E/flutter (13139): #31     _StreamController.add (dart:async/stream_controller.dart:554:5)
E/flutter (13139): #32     _Socket._onData (dart:io-patch/socket_patch.dart:2160:41)
E/flutter (13139): #33     _rootRunUnary (dart:async/zone.dart:1370:13)
E/flutter (13139): #34     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (13139): #35     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (13139): #36     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (13139): #37     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (13139): #38     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
E/flutter (13139): #39     _StreamController._add (dart:async/stream_controller.dart:607:7)
E/flutter (13139): #40     _StreamController.add (dart:async/stream_controller.dart:554:5)
E/flutter (13139): #41     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1696:33)
E/flutter (13139): #42     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1208:14)
E/flutter (13139): #43     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (13139): #44     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

On Phoenix I sent this:

APP.Endpoint.broadcast!("room:chat", "new:msg",  %{user: "SYSTEM", body: "PING"})

I was able to fix this by updating:

bool isMember(
      String topicParam, String event, Map payload, String joinRefParam) {

to

bool isMember(
      String topicParam, String event, Map payload, String? joinRefParam) {

I am fairly new to Dart so I am not sure if there was maybe some missing Null safety implementation?

Quantum-Sicarius commented 3 years ago

@macoshita any input on this maybe?

macoshita commented 3 years ago

I'm sorry, thank you for the report. Maybe this should be done,

bool isMember( String topicParam, String event, Map payload, [String joinRefParam]) {

I will make a PR as soon as possible.

macoshita commented 3 years ago

@Quantum-Sicarius I fixed it in this PR, so you can try it if you like.

Quantum-Sicarius commented 3 years ago

Awesome! Thanks for all your effort @macoshita and @mfeckie!