nhost-dart
nhost-dart copied to clipboard
Subscription stream error when init (restart is good)
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!);
}
});
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?
I've run into this bug completely separately from nhost: https://github.com/gql-dart/gql/issues/294. It looks like a fix has been merged (https://github.com/gql-dart/gql/pull/354) but I don't think it's in a release yet. You could probably override the dependency to use the git URL, though.
@marcusrohden nope
Lets wait for the release, maybe wonderful person @szilarddoro could make that happen =)
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 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
https://github.com/gql-dart/gql/issues/294#issuecomment-1025264312
I made a fork from agent3bood repo and have been using it for the whole day with no issues.
gql_websocket_link is now 0.3.4 which should include bugfix for this issue. this can be updated now i believe.
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
Just published another new version https://pub.dev/publishers/nhost.io/packages
all packages have BETA dev.8 you can try