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

Null check operator used on a null value in SocketClient.onConnectionLost #1379

Open
vytautas-pranskunas- opened this issue Sep 16, 2023 · 2 comments

Comments

@vytautas-pranskunas-
Copy link
Contributor

my error logger reports follwoing error:

_TypeError
 
websocket_client.dart in SocketClient.onConnectionLost

Ongoing
Level: Error
Null check operator used on a null value
websocket_client.dart in SocketClient.onConnectionLost at line 371 within graphql
In App
websocket_client.dart in SocketClient._connect at line 365 within graphql
@priyanshnama
Copy link

can i work on this

aarsham added a commit to aarsham/graphql-flutter that referenced this issue Feb 20, 2024
**Fixes**

- Removed unnecessary null checks(!) on SocketChannel instance in SocketClient onConnectionLost() method which cause an error when client cannot connect (zino-hofmann#1379). this prevents reconnecting when there is a working connection later.
aarsham added a commit to aarsham/graphql-flutter that referenced this issue Feb 20, 2024
**Fixes**
- Removed unnecessary null checks(!) on SocketChannel instance in SocketClient onConnectionLost() method which cause an error when client cannot connect (zino-hofmann#1379). this prevents reconnecting when there is a working connection later.
aarsham added a commit to aarsham/graphql-flutter that referenced this issue Apr 8, 2024
**Fixes**
- Removed unnecessary null checks(!) on SocketChannel instance in SocketClient onConnectionLost() method which cause an error when client cannot connect (zino-hofmann#1379). this prevents reconnecting when there is a working connection later.
@WieFel
Copy link

WieFel commented May 8, 2024

I have the same problem on Android (API 34). It crashes even the whole emulator at app start.
On web and even iOS, my code works fine.

E/flutter ( 4262): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 4262): #0      SocketClient.onConnectionLost (package:graphql/src/links/websocket_link/websocket_client.dart:375:29)
E/flutter ( 4262): #1      SocketClient._connect (package:graphql/src/links/websocket_link/websocket_client.dart:369:7)
E/flutter ( 4262): <asynchronous suspension>

My client initialisation code looks like this:

final errorLink = ErrorLink(
  onException: (request, forward, exception) {
    logger.e(exception);
    return null;
  },
);

final WebSocketLink websocketLink = WebSocketLink(
  websocketBackendUrl,
  config: SocketClientConfig(
      autoReconnect: true,
      inactivityTimeout: const Duration(seconds: 30),
      initialPayload: () async {
        // ... some authentication logic
      }),
  subProtocol: GraphQLProtocol.graphqlTransportWs,
);

Link link = errorLink.concat(websocketLink);

return GraphQLClient(
  link: link,
  cache: GraphQLCache(store: InMemoryStore()),
  defaultPolicies: DefaultPolicies(
    query: Policies(fetch: FetchPolicy.noCache),
    mutate: Policies(fetch: FetchPolicy.noCache),
  ),
);

The error occurres even when using version 5.2.0-beta.7 of the package (#1410).

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

No branches or pull requests

3 participants