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

TypeError: Instance of 'HttpRequestEventTarget': type 'HttpRequestEventTarget' is not a subtype of type 'HttpRequest' #2157

Closed
ZhangZeQiao opened this issue Mar 24, 2024 · 4 comments

Comments

@ZhangZeQiao
Copy link

Package

dio

Version

5.4.1

Operating-System

Web

Adapter

Default Dio

Output of flutter doctor -v

No response

Dart Version

3.3.0

Steps to Reproduce

flutter web
flutter_windows_3.19.4-stable
dio: ^5.4.1

Expected Result

Normal request

Actual Result

request failure
“TypeError: Instance of 'HttpRequestEventTarget': type 'HttpRequestEventTarget' is not a subtype of type 'HttpRequest'”

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

Please provide a minimal reproducible example.

@AlexV525 AlexV525 added the h: need more info Further information is requested label Mar 24, 2024
@ZhangZeQiao
Copy link
Author

Please provide a minimal reproducible example.

Just using the official demo will cause it to happen !

import 'package:dio/dio.dart';

final dio = Dio();

void getHttp() async {
final response = await dio.get('https://dart.dev');
print(response);
}

@AlexV525
Copy link
Member

This is how the example works, without your issue:

Downloading Web SDK...
This application is not configured to build on the web.
To add web support to a project, run `flutter create .`.
Launching lib\main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:55552/dUeW_BJIYt4=/ws
Debug service listening on ws://127.0.0.1:55552/dUeW_BJIYt4=/ws
Debug service listening on ws://127.0.0.1:55552/dUeW_BJIYt4=/ws
*** Request ***
uri: https://httpbin.org/status/404
method: GET
responseType: ResponseType.plain
followRedirects: true
persistentConnection: true
connectTimeout: 0:00:03.000000
sendTimeout: null
receiveTimeout: null
receiveDataWhenStatusError: true
extra: {}
headers:

*** DioException ***:
uri: https://httpbin.org/status/404
DioException [bad response]: This exception was thrown because the response has a status code of 404 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 404 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.

uri: https://httpbin.org/status/404
statusCode: 404
headers:
 content-length: 0
 content-type: text/html; charset=utf-8


DioException [bad response]: This exception was thrown because the response has a status code of 404 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 404 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.

Error: Instance of 'InterceptorState<DioException>'
    dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 843:28                get current
packages/dio/src/dio_mixin.dart 350:36                                            request
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                _async
packages/dio/src/dio_mixin.dart 333:33                                            request
packages/dio/src/dio_mixin.dart 64:12                                             get
packages/dio_flutter_example/main.dart 54:24                                      <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                _async
packages/dio_flutter_example/main.dart 50:26                                      <fn>
packages/flutter/src/material/ink_well.dart 1183:21                               handleTap
packages/flutter/src/gestures/recognizer.dart 315:24                              invokeCallback
packages/flutter/src/gestures/tap.dart 652:11                                     handleTapUp
packages/flutter/src/gestures/tap.dart 309:5                                      [_checkUp]
packages/flutter/src/gestures/tap.dart 242:7                                      handlePrimaryPointer
packages/flutter/src/gestures/recognizer.dart 670:9                               handleEvent
packages/flutter/src/gestures/pointer_router.dart 98:7                            [_dispatch]
packages/flutter/src/gestures/pointer_router.dart 143:9                           <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/linked_hash_map.dart 21:7           forEach
packages/flutter/src/gestures/pointer_router.dart 141:17                          [_dispatchEventToRoutes]
packages/flutter/src/gestures/pointer_router.dart 127:7                           route
packages/flutter/src/gestures/binding.dart 495:5                                  handleEvent
packages/flutter/src/gestures/binding.dart 475:14                                 dispatchEvent
packages/flutter/src/rendering/binding.dart 425:11                                dispatchEvent
packages/flutter/src/gestures/binding.dart 420:7                                  [_handlePointerEventImmediately]
packages/flutter/src/gestures/binding.dart 383:5                                  handlePointerEvent
packages/flutter/src/gestures/binding.dart 330:7                                  [_flushPointerEventQueue]
packages/flutter/src/gestures/binding.dart 299:9                                  [_handlePointerDataPacket]
lib/_engine/engine/platform_dispatcher.dart 1405:5                                invoke1
lib/_engine/engine/platform_dispatcher.dart 332:5                                 invokeOnPointerDataPacket
lib/_engine/engine/pointer_binding.dart 398:30                                    [_sendToFramework]
lib/_engine/engine/pointer_binding.dart 224:7                                     onPointerData
lib/_engine/engine/pointer_binding.dart 1001:20                                   <fn>
lib/_engine/engine/pointer_binding.dart 930:7                                     <fn>
lib/_engine/engine/pointer_binding.dart 531:9                                     loggedHandler
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 426:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 431:39  dcall


dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 327:10  createErrorWithStack
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 265:28            _throw
dart-sdk/lib/core/errors.dart 120:5                                           throwWithStackTrace
dart-sdk/lib/async/zone.dart 1386:11                                          callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7            <fn>

@AlexV525
Copy link
Member

AlexV525 commented Mar 25, 2024

Both classes are provided by the Dart SDK, it should be nothing related to Dio. Please consider asking the Dart team for help.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
@AlexV525 AlexV525 added i: not related and removed h: need more info Further information is requested h: need triage This issue needs to be categorized s: bug Something isn't working labels Apr 3, 2024
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

2 participants