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

HttpException: Connection closed before response was received #2143

Closed
myronZhouJ opened this issue Mar 16, 2024 · 1 comment
Closed

HttpException: Connection closed before response was received #2143

myronZhouJ opened this issue Mar 16, 2024 · 1 comment
Labels
i: duplicate This issue or pull request already exists

Comments

@myronZhouJ
Copy link

myronZhouJ commented Mar 16, 2024

Package

dio

Version

5.4.1

Operating-System

iOS

Adapter

Default Dio

Output of flutter doctor -v

• Flutter version 3.19.2 on channel stable at
      /Users/zhoujing/fvm/versions/3.19.2
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7482962148 (3 weeks ago), 2024-02-27 16:51:22 -0500
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/zhoujing/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/zhoujing/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2023.1)
    • 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
      17.0.7+0-17.0.7b1000.6-10550314)

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

Dart Version

3.3.0

Steps to Reproduce

Cancel a previously completed task, causing other ongoing tasks to fail

  Future<void> test() async {
    final dio = Dio();
    try {
      CancelToken testTask = CancelToken();
      final response = await dio.get('https://jandan.net/api/post/dot',
          cancelToken: testTask);
      print('Success:$response');
      Future<void>.delayed(const Duration(milliseconds: 30), () {
        print('------cancel------${DateTime.now()}');
        testTask.cancel();
      });

      dio
          .get('https://jandan.net/api/post/dot')
          .then((value) => print(value))
          .catchError((e) {
        print('------error-------${DateTime.now()}-$e');
      });
    } catch (e) {
      print(e);
    }
  }

Expected Result

working

Actual Result

flutter: Success:{"code":0,"msg":"success","data":{"logged_in":false,"admin_domain":"http://x.jandan.net"}}
flutter: ------cancel------2024-03-16 23:04:03.181944
flutter: ------error-------2024-03-16 23:04:03.182706-DioException [unknown]: null
Error: HttpException: Connection closed before response was received, uri = https://jandan.net/api/post/dot

@myronZhouJ myronZhouJ added h: need triage This issue needs to be categorized s: bug Something isn't working labels Mar 16, 2024
@AlexV525
Copy link
Member

Duplicate of #2135

@AlexV525 AlexV525 marked this as a duplicate of #2135 Mar 16, 2024
@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2024
@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 Mar 16, 2024
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