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

type '(dynamic) => Map<String, dynamic>?' is not a subtype of type '(dynamic) => FutureOr<Map<String, dynamic>>?' of 'function result' #294

Closed
antholeole opened this issue Jan 29, 2022 · 11 comments · Fixed by #354

Comments

@antholeole
Copy link

Hi there! I left my app open overnight, and ended up with over four thousand (4000!) errors originating from this package with the error message type '(dynamic) => Map<String, dynamic>?' is not a subtype of type '(dynamic) => FutureOr<Map<String, dynamic>>?' of 'function result'.

I've seen this error before but haven't thought much of it until I began getting messages from sentry about over use. Here's a small stack trace that sentry gives me:

link.dart in WebSocketLink._parseSocketMessage within gql_websocket_link
link.dart in WebSocketLink._connect.<fn> at line 206:37 within gql_websocket_link
link.dart in WebSocketLink._connect.<fn> at line 201:31 within gql_websocket_link

and here are my versions:

  gql: 0.13.0
  gql_link: ^0.4.0
  gql_http_link: ^0.4.0
  ferry_flutter: ^0.5.4
  gql_exec: ^0.3.0
  gql_websocket_link: ^0.3.1

is this seen anywhere? how can I fix this error? Thanks!

@antholeole
Copy link
Author

antholeole commented Jan 30, 2022

seems to come from

static Map<String, dynamic>? _defaultGraphQLSocketMessageDecoder(
dynamic message) =>
json.decode(message as String) as Map<String, dynamic>?;

I'm not sure why this is, though: doesn't FutureOr mean that we can return the map or a future of the map? and thus, it is a subtype of the future?

For now, it works if I just mark the function async, but I have to go into my pub cache and change it. That's not ideal!

@agent3bood
Copy link
Collaborator

Thanks for the report, the issue seems to be on the Map that is needed to be non-nullable, but the _defaultGraphQLSocketMessageDecoder returns Map?.
Currently I cannot test this or reproduce this issue so I am asking if you can test this branch https://github.com/agent3bood/gql/tree/issue/294 and let me know how it goes.

@antholeole
Copy link
Author

Thanks for getting back to me so quickly and getting a fix in! I'll switch to that branch and let you know if I stop seeing the problem.

It happens intermittently, but rather consistently over a 1-2 hour period. I'll let you know once I get a chance to test, thanks!

@antholeole
Copy link
Author

Update: been testing with this pubspec.yaml:

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

and it's been holding up with no errors for a couple of hours. I'll leave it running overnight and see if it comes back, but it looks like a good sign :) Thank you!

@spakanati
Copy link

I have the same issue and it does appear to be solved by using https://github.com/agent3bood/gql/tree/issue/294 -- any chance those changes will end up merged?

@knaeckeKami
Copy link
Collaborator

@agent3bood could you open a MR for this?

@MichalNemec
Copy link

Hello, when its going to be on pub.dev?

@knaeckeKami
Copy link
Collaborator

Hello, it is released as alpha version on pub.dev. (0.3.4-alpha+1661890990262)
But I'll update it to stable soon.

@MichalNemec
Copy link

Hello, any update? @knaeckeKami

@knaeckeKami
Copy link
Collaborator

done

@MichalNemec
Copy link

amazing, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants