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

CancelToken.cancel should NOT return an uncaught exception #1940

Closed
YDA93 opened this issue Aug 17, 2023 · 2 comments
Closed

CancelToken.cancel should NOT return an uncaught exception #1940

YDA93 opened this issue Aug 17, 2023 · 2 comments
Labels
i: duplicate This issue or pull request already exists

Comments

@YDA93
Copy link

YDA93 commented Aug 17, 2023

Package

dio

Version

^5.3.2

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.13.0, on macOS 13.5.1 22G90 darwin-arm64, locale en-KW)
    • Flutter version 3.13.0 on channel stable at /Users/yousefalmutairi/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision efbf63d9c6 (2 days ago), 2023-08-15 21:05:06 -0500
    • Engine revision 1ac611c64e
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/yousefalmutairi/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

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

[✓] Connected device (3 available)
    • iPhone 11 Pro Max (mobile) • 00008030-000134911482802E • ios            • iOS 16.6 20G75
    • macOS (desktop)            • macos                     • darwin-arm64   • macOS 13.5.1 22G90 darwin-arm64
    • Chrome (web)               • chrome                    • web-javascript • Google Chrome 115.0.5790.170
    ! Error: (null) needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between the iPhone and Xcode. Both devices may also need to be restarted and
      unlocked. (code 1)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Dart Version

3.1.0

Steps to Reproduce

  1. Upgrade to Flutter Channel stable 3.13.0
  2. call cancelToken.cancel();

Expected Result

No uncaught exception should appear and i already handle all dio exceptions.

    try {
      final httpResponse = await request();
      return _validateStatusCode(httpResponse);
    } on DioException catch (error, stackTrace) {
      // SocketException
      if (error.type == DioExceptionType.connectionError) {
        throw const ExceptionNetwork(ExceptionNetworkType.socket);
      }

      // Timeout exceptions
      if ([
        DioExceptionType.connectionTimeout,
        DioExceptionType.receiveTimeout,
        DioExceptionType.sendTimeout,
      ].contains(error.type)) {
        throw const ExceptionNetwork(ExceptionNetworkType.timeout);
      }

      // Requested cancelled exception
      if (error.type == DioExceptionType.cancel) {
        throw const ExceptionNetwork(ExceptionNetworkType.cancelled);
      }

      // Unknown exception
      unawaited(
        FirebaseCrashlytics.instance.recordError(
          error.type,
          stackTrace,
          reason: {
            'DioError': url,
          },
        ),
      );
      throw const ExceptionNetwork(ExceptionNetworkType.undefined);
    }

Actual Result

Screenshot 2023-08-17 at 10 30 09 PM

@YDA93 YDA93 added h: need triage This issue needs to be categorized s: bug Something isn't working labels Aug 17, 2023
@YDA93
Copy link
Author

YDA93 commented Aug 17, 2023

Reverting back to Flutter 3.10.6 fixes the issue.

@AlexV525
Copy link
Member

Duplicated of #1869.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 17, 2023
@AlexV525 AlexV525 added i: duplicate This issue or pull request already exists and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants