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 problem in Flutter version 3.13.2 #1953

Closed
menghui0330 opened this issue Sep 7, 2023 · 9 comments
Closed

CancelToken problem in Flutter version 3.13.2 #1953

menghui0330 opened this issue Sep 7, 2023 · 9 comments

Comments

@menghui0330
Copy link

Package

dio

Version

5.3.2

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.13.2, on macOS 13.5.1 22G90 darwin-arm64, locale en-MY)
    • Flutter version 3.13.2 on channel stable at /Users/menghui/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (2 weeks ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/menghui/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • 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

[✓] Android Studio (version 2021.3)
    • 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
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

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

[✓] Connected device (1 available)
    • iPhone SE (3rd generation) (mobile) • F1DC1D3B-48E9-4803-A860-A2CD6F1054FE • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)

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

• No issues found!

Dart Version

3.1.0

Steps to Reproduce

  1. Call an API with cancelation token provided
  2. Wait for response
  3. Trigger cancel token

Expected Result

Nothing happen

Actual Result

Exception

Screenshot 2023-09-07 at 5 45 14 PM

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

Never had this problem with flutter 3.10, but keep getting uncaught exception in 3.13

@kuhnroyal
Copy link
Member

Please see the comment and answers: #1869 (comment)
In short, this is likely a change in Flutter and/or its interaction with VSCode, nothing we can do anything about.

@lonelyteapot
Copy link
Contributor

This may have been fixed in Flutter master. Reference: dart-lang/sdk#47985

@kuhnroyal
Copy link
Member

Yea I think we can close this issue, please follow the Dart SDK issue for updates to Dart/Flutter.
There is nothing dio can do about it.

@kuhnroyal kuhnroyal closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2023
@AlexV525 AlexV525 added i: out of support and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Sep 11, 2023
@YDA93
Copy link

YDA93 commented Oct 30, 2023

still exists in Flutter Channel stable, 3.13.9. the bug is annoying

@kuhnroyal
Copy link
Member

Please follow the mentioned Dart SDK issue, nothing we can do here.

@tomekit
Copy link

tomekit commented Nov 7, 2023

In short, this is likely a change in Flutter and/or its interaction with VSCode, nothing we can do anything about.

We experience the same in the Android Studio IDE and we suspect this is what breaks the cancel token for stream response as described here: #2025

Present in the function: dio-5.3.3/lib/src/dio_mixin.dart:

 @internal
  static Future<T> listenCancelForAsyncTask<T>(
    CancelToken? cancelToken,
    Future<T> future,
  ) {
    return Future.any([
      if (cancelToken != null) cancelToken.whenCancel.then((e) {
        throw e;
      }),
      future,
    ]);
  }

@tomekit
Copy link

tomekit commented Nov 12, 2023

I think this issue shall be reopened.

The related Dart issue that was mentioned in this ticket: dart-lang/sdk#47985 or #1869 (comment) applies to debugger problems, however cancellation doesn't seem to work fine regardless of IDE / debugger used. It doesn't even work in the release version of the app.

In other words cancellation doesn't work for Dio as reported in this issue: #2025 even if app is built using release mode.

This issue was closed as "Out of support" without valid references to external issues.
It would be good to narrow down the problem to either Dio itself or Dart SDK... and if the issue lies within Dart SDK it would be great to link to any existing issue or create a new one: https://github.com/dart-lang/sdk/issues

@AlexV525
Copy link
Member

There is nothing we can do with this ticket because it's out of support with its given information. The most relevant references are already referenced so we are more likely to work on new, more detailed, and more precised issue if possible.

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

No branches or pull requests

6 participants