Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription stream error when init (restart is good) #84

Open
MichalNemec opened this issue Oct 3, 2022 · 8 comments
Open

Subscription stream error when init (restart is good) #84

MichalNemec opened this issue Oct 3, 2022 · 8 comments
Assignees
Labels
Investigate Working to figure out what's wrong!

Comments

@MichalNemec
Copy link
Contributor

MichalNemec commented Oct 3, 2022

Hello,

I have subscription stream and whenever i init the app and the subscription is on homepage i get error. Whenever i do restart/R reload, its working as intended.

its about gql_websocket_link

 ---------- ERROR ----------
I/flutter (15323): [2022-10-03 17:42:36.705670 | Catcher | INFO] type '(dynamic) => Map<String, dynamic>?' is not a subtype of type '(dynamic) => FutureOr<Map<String, dynamic>>?' of 'function result'
I/flutter (15323): [2022-10-03 17:42:36.705710 | Catcher | INFO]
I/flutter (15323): [2022-10-03 17:42:36.705737 | Catcher | INFO] ------- STACK TRACE -------
I/flutter (15323): [2022-10-03 17:42:36.709501 | Catcher | INFO] #0      WebSocketLink.graphQLSocketMessageDecoder (package:gql_websocket_link/src/link.dart)
package:gql_websocket_link/src/link.dart:1
I/flutter (15323): [2022-10-03 17:42:36.709611 | Catcher | INFO] #1      WebSocketLink._parseSocketMessage
package:gql_websocket_link/src/link.dart:299
I/flutter (15323): [2022-10-03 17:42:36.709974 | Catcher | INFO] #2      WebSocketLink._connect.<anonymous closure>
package:gql_websocket_link/src/link.dart:206
I/flutter (15323): [2022-10-03 17:42:36.710075 | Catcher | INFO] #3      _rootRunUnary (dart:async/zone.dart:1399:47)
I/flutter (15323): [2022-10-03 17:42:36.710255 | Catcher | INFO] #4      _CustomZone.runUnary (dart:async/zone.dart:1300:19)
I/flutter (15323): [2022-10-03 17:42:36.710291 | Catcher | INFO] #5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
I/flutter (15323): [2022-10-03 17:42:36.710533 | Catcher | INFO] #6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (15323): [2022-10-03 17:42:36.710599 | Catcher | INFO] #7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter (15323): [2022-10-03 17:42:36.710629 | Catcher | INFO] #8      _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
I/flutter (15323): [2022-10-03 17:42:36.710806 | Catcher | INFO] #9      _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10)
I/flutter (15323): [2022-10-03 17:42:36.710849 | Catcher | INFO] #10     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
I/flutter (15323): [2022-10-03 17:42:36.710888 | Catcher | INFO] #11     _rootRunUnary (dart:async/zone.dart:1399:47)
I/flutter (15323): [2022-10-03 17:42:36.711214 | Catcher | INFO] #12     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
I/flutter (15323): [2022-10-03 17:42:36.711270 | Catcher | INFO] #13     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
I/flutter (15323): [2022-10-03 17:42:36.711300 | Catcher | INFO] #14     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (15323): [2022-10-03 17:42:36.711330 | Catcher | INFO] #15     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter (15323): [2022-10-03 17:42:36.711358 | Catcher | INFO] #16     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
I/flutter (15323): [2022-10-03 17:42:36.711390 | Catcher | INFO] #17     _StreamController._add (dart:async/stream_controller.dart:648:7)
I/flutter (15323): [2022-10-03 17:42:36.711417 | Catcher | INFO] #18     _rootRunUnary (dart:async/zone.dart:1399:47)
I/flutter (15323): [2022-10-03 17:42:36.711444 | Catcher | INFO] #19     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
I/flutter (15323): [2022-10-03 17:42:36.711966 | Catcher | INFO] #20     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
I/flutter (15323): [2022-10-03 17:42:36.712069 | Catcher | INFO] #21     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (15323): [2022-10-03 17:42:36.712724 | Catcher | INFO] #22     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter (15323): [2022-10-03 17:42:36.712984 | Catcher | INFO] #23     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
I/flutter (15323): [2022-10-03 17:42:36.713037 | Catcher | INFO] #24     _StreamController._add (dart:async/stream_controller.dart:648:7)
I/flutter (15323): [2022-10-03 17:42:36.713066 | Catcher | INFO] #25     _StreamController.add (dart:async/stream_controller.dart:596:5)
I/flutter (15323): [2022-10-03 17:42:36.713103 | Catcher | INFO] #26     new _WebSocketImpl._fromSocket.<anonymous closure> (dart:_http/websocket_impl.dart:1144:21)
I/flutter (15323): [2022-10-03 17:42:36.713140 | Catcher | INFO] #27     _rootRunUnary (dart:async/zone.dart:1399:47)
I/flutter (15323): [2022-10-03 17:42:36.713168 | Catcher | INFO] #28     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
I/flutter (15323): [2022-10-03 17:42:36.713403 | Catcher | INFO] #29     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
I/flutter (15323): [2022-10-03 17:42:36.715590 | Catcher | INFO] #30     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (15323): [2022-10-03 17:42:36.717215 | Catcher | INFO] #31     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter (15323): [2022-10-03 17:42:36.717451 | Catcher | INFO] #32     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
I/flutter (15323): [2022-10-03 17:42:36.718218 | Catcher | INFO] #33     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
I/flutter (15323): [2022-10-03 17:42:36.718592 | Catcher | INFO] #34     _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23)
I/flutter (15323): [2022-10-03 17:42:36.719887 | Catcher | INFO] #35     _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46)
I/flutter (15323): [2022-10-03 17:42:36.719945 | Catcher | INFO] #36     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
I/flutter (15323): [2022-10-03 17:42:36.719974 | Catcher | INFO] #37     _rootRunUnary (dart:async/zone.dart:1399:47)
I/flutter (15323): [2022-10-03 17:42:36.720001 | Catcher | INFO] #38     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
I/flutter (15323): [2022-10-03 17:42:36.720245 | Catcher | INFO] #39     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
I/flutter (15323): [2022-10-03 17:42:36.720284 | Catcher | INFO] #40     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (15323): [2022-10-03 17:42:36.720510 | Catcher | INFO] #41     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter (15323): [2022-10-03 17:42:36.720545 | Catcher | INFO] #42     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
I/flutter (15323): [2022-10-03 17:42:36.720571 | Catcher | INFO] #43     _StreamController._add (dart:async/stream_controller.dart:648:7)
I/flutter (15323): [2022-10-03 17:42:36.720596 | Catcher | INFO] #44     _StreamController.add (dart:async/stream_controller.dart:596:5)
I/flutter (15323): [2022-10-03 17:42:36.720894 | Catcher | INFO] #45     _Socket._onData (dart:io-patch/socket_patch.dart:2324:41)
I/flutter (15323): [2022-10-03 17:42:36.720934 | Catcher | INFO] #46     _rootRunUnary (dart:async/zone.dart:1407:13)
I/flutter (15323): [2022-10-03 17:42:36.720961 | Catcher | INFO] #47     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
I/flutter (15323): [2022-10-03 17:42:36.720987 | Catcher | INFO] #48     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
I/flutter (15323): [2022-10-03 17:42:36.721015 | Catcher | INFO] #49     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (15323): [2022-10-03 17:42:36.721042 | Catcher | INFO] #50     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
I/flutter (15323): [2022-10-03 17:42:36.721067 | Catcher | INFO] #51     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
I/flutter (15323): [2022-10-03 17:42:36.721093 | Catcher | INFO] #52     _StreamController._add (dart:async/stream_controller.dart:648:7)
I/flutter (15323): [2022-10-03 17:42:36.721253 | Catcher | INFO] #53     _StreamController.add (dart:async/stream_controller.dart:596:5)
I/flutter (15323): [2022-10-03 17:42:36.721290 | Catcher | INFO] #54     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1849:33)
I/flutter (15323): [2022-10-03 17:42:36.721317 | Catcher | INFO] #55     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
I/flutter (15323): [2022-10-03 17:42:36.721342 | Catcher | INFO] #56     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
I/flutter (15323): [2022-10-03 17:42:36.721367 | Catcher | INFO] #57     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
I/flutter (15323): [2022-10-03 17:42:36.721394 | Catcher | INFO]
I/flutter (15323): [2022-10-03 17:42:36.721420 | Catcher | INFO] ======================================================================

does anybody know whats wrong?

my implementation, which is causing this issue is:

final profile5LastActivitiesProvider =
    StreamProvider.autoDispose.family<UserActivities, GraphQLClient>((ref, graphql) async* {
  final subscription = graphql.subscribe(
    SubscriptionOptions(
      document: gql(GraphQLQuery.subGet5LastActivities),
      fetchPolicy: FetchPolicy.cacheAndNetwork,
    ),
  );

  await for (final value in subscription) {
    yield UserActivities.fromJson(value.data!);
  }
});
@marcusrohden
Copy link

marcusrohden commented Oct 16, 2022

I'm having the same issue. It's the only subscription I have in the code running beside the auth token refresh built by nhost.

@MichalNemec have you found any solution yet?

@spakanati
Copy link
Contributor

I've run into this bug completely separately from nhost: gql-dart/gql#294. It looks like a fix has been merged (gql-dart/gql#354) but I don't think it's in a release yet. You could probably override the dependency to use the git URL, though.

@MichalNemec
Copy link
Contributor Author

@marcusrohden nope

Lets wait for the release, maybe wonderful person @szilarddoro could make that happen =)

@szilarddoro
Copy link
Contributor

You're right @spakanati. The latest release of gql-dart/gql was on the 11th of August, so that fix is not released yet. I don't think there is too much we can do about this issue now 🙁

@marcusrohden
Copy link

@marcusrohden nope

Lets wait for the release, maybe wonderful person @szilarddoro could make that happen =)

for a temporary workaround, you can override the dependency.

dependency_overrides:
  gql_websocket_link: 
    git:
      url: https://github.com/agent3bood/gql.git
      path: links/gql_websocket_link
      ref: issue/294

gql-dart/gql#294 (comment)

I made a fork from agent3bood repo and have been using it for the whole day with no issues.

@MichalNemec
Copy link
Contributor Author

MichalNemec commented Oct 26, 2022

gql_websocket_link is now 0.3.4 which should include bugfix for this issue.
this can be updated now i believe.

MichalNemec added a commit to MichalNemec/nhost-dart that referenced this issue Nov 8, 2022
Updating gql_websocket_link from 0.3.1 to 0.3.4

fix: nhost#84
@mhadaily mhadaily self-assigned this Dec 4, 2022
@mhadaily mhadaily added the Investigate Working to figure out what's wrong! label Dec 4, 2022
@mhadaily
Copy link
Contributor

mhadaily commented Dec 6, 2022

I have just released a new dev version, please give it a try and let me know how it works
https://pub.dev/packages/nhost_graphql_adapter/versions/3.0.0-dev.0

@mhadaily
Copy link
Contributor

Just published another new version https://pub.dev/publishers/nhost.io/packages

all packages have BETA dev.8 you can try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Working to figure out what's wrong!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants