dailydrip / absinthe_socket

A dart client for GraphQL subscriptions via Absinthe sockets.
https://www.smoothterminal.com
MIT License
6 stars 10 forks source link

Error Casting #7

Closed redDwarf03 closed 2 years ago

redDwarf03 commented 2 years ago

hello i meet this issue

flutter: connect absinthe socket 1
flutter: connect absinthe socket 2
flutter: connect absinthe socket 3
flutter: connect absinthe socket 4
flutter: connect absinthe socket 5

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type '(Map<dynamic, dynamic>) => Null' is not a subtype of type '(Map<dynamic, dynamic>?) => dynamic' in type cast
#0      AbsintheSocket._handlePush
#1      AbsintheSocket._pushRequest
#2      AbsintheSocket._sendQueuedPushes.<anonymous closure>
#3      List.forEach (dart:core-patch/growable_array.dart:433:8)
#4      AbsintheSocket._sendQueuedPushes
#5      PhoenixPush.matchReceive.<anonymous closure>
#6      Iterable.forEach (dart:core/iterable.dart:325:35)
#7      PhoenixPush.matchReceive
#8      PhoenixPush.startTimeout.<anonymous closure>
#9      PhoenixChannel.trigger.<anonymous closure>
#10     Iterable.forEach (dart:core/iterable.dart:325:35)
#11     PhoenixChannel.trigger
#12     new PhoenixChannel.<anonymous closure>
#13     PhoenixChannel.trigger.<anonymous closure>
#14     Iterable.forEach (dart:core/iterable.dart:325:35)
#15     PhoenixChannel.trigger
#16     PhoenixSocket._onConnMessage.<anonymous closure>
#17     Iterable.forEach (dart:core/iterable.dart:325:35)
#18     PhoenixSocket._onConnMessage
#19     PhoenixIoConnection.onMessage.<anonymous closure>
#20     _rootRunUnary (dart:async/zone.dart:1434:47)
#21     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#22     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#23     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#24     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#25     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#26     _StreamController._add (dart:async/stream_controller.dart:648:7)
#27     _StreamController.add (dart:async/stream_controller.dart:596:5)
#28     new _WebSocketImpl._fromSocket.<anonymous closure> (dart:_http/websocket_impl.dart:1144:21)
#29     _rootRunUnary (dart:async/zone.dart:1434:47)
#30     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#31     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#32     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#33     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#34     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#35     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#36     _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23)
#37     _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46)
#38     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#39     _rootRunUnary (dart:async/zone.dart:1434:47)
#40     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#41     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#42     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#43     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#44     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#45     _StreamController._add (dart:async/stream_controller.dart:648:7)
#46     _StreamController.add (dart:async/stream_controller.dart:596:5)
#47     _Socket._onData (dart:io-patch/socket_patch.dart:2314:41)
#48     _rootRunUnary (dart:async/zone.dart:1442:13)
#49     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#50     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#51     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#52     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#53     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#54     _StreamController._add (dart:async/stream_controller.dart:648:7)
#55     _StreamController.add (dart:async/stream_controller.dart:596:5)
#56     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1839:33)
#57     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
#58     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#59     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

with this code

void waitConfirmations(String address, Function handler) {
    String host =
        Uri.parse(endpoint!).host + ':' + Uri.parse(endpoint!).port.toString();
    AbsintheSocket _socket =
        AbsintheSocket('ws://' + host + '/socket/websocket');
    final String operation =
        'subscription { transactionConfirmed(address: \\"$address\\") { nbConfirmations } } }';

    Observer _categoryObserver = Observer(onAbort: () {
      print('abort');
    }, onError: (err) {
      print('err');
      throw err;
    }, onResult: (result) {
      print('result: ' + result);
      print('result.data.transactionConfirmed: ' +
          result.data.transactionConfirmed);

      if (result.data.transactionConfirmed) {
        print('result.data.transactionConfirmed.nbConfirmations: ' +
            result.data.transactionConfirmed.nbConfirmations);
        return result.data.transactionConfirmed.nbConfirmations;
      }
      throw result;
    }, onStart: () {
      print('open');
    });

    Notifier notifier = _socket.send(GqlRequest(operation: operation));
    return notifier.observe(_categoryObserver);
  }
redDwarf03 commented 2 years ago

@Anushka Agrawal any idea ?