Graphql-flutter: Software caused connection abort

Created on 24 Sep 2019  ·  6Comments  ·  Source: zino-app/graphql-flutter

I need to upload logs, for example every 1 minute, if i have the internet everything is fine, but if i lose connection, i get this error:
Снимок экрана 2019-09-24 в 8 39 29
try...catch, catchError don't catch error and app just stops.

Code example:

Future<void> _uploadLogs() async{
  try{
    final QueryResult result = await GraphQLProvider.of(context).value.mutate(
      MutationOptions(
        document: document,
        variables: <String, List<dynamic>>{
          'input': logs
        }
      ));
    if(result.hasErrors){
      throw result.errors;
    }
    if(result.data != null){
      print(result.data);
    }
  }
  catch(error){
    print(error);
  }
}

Doctor -v:

[✓] Flutter (Channel dev, v1.10.5, on Mac OS X 10.14.6 18G95, locale ru-RU)
    • Flutter version 1.10.5 at /Users/ads/Library/flutter
    • Framework revision 3cf88fed6d (5 days ago), 2019-09-18 23:09:41 -0400
    • Engine revision 33ad6757e8
    • Dart version 2.6.0 (build 2.6.0-dev.0.0 cb80ea7ba9)


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/ads/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/ads/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.


[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • CocoaPods version 1.6.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.38.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • ZTE BLADE A0622 • 320376181424 • android-arm • Android 7.1.1 (API 25)
bug

Most helpful comment

right - #393 will likely solve this issue

All 6 comments

Can you try the beta version, I think this PR on reconnecting to a WebSocket when offline might have solved your issue.

If that's the case, the other option is to monitor connection state and maintain a queue for mutations, once the user is online, the perform the mutations. This is tracked by this issue here.

@mainawycliffe i'm using graphql_flutter: ^2.1.1-beta.2

@Goolpe I see, I will look into this, probably error handling in this section needs improvement.

@micimize you were working on improving error handling on your last PR, have you fixed this or can I take a look at it.

right - #393 will likely solve this issue

@Goolpe does the issue still exist on the current beta?

I'm trying to reproduce error now, i think that issue is gone, thank you

Was this page helpful?
0 / 5 - 0 ratings