firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.63k stars 3.95k forks source link

🐛 [firebase_storage] Error while uploading image to firebase storage #9203

Closed OutdatedGuy closed 2 years ago

OutdatedGuy commented 2 years ago

Bug report

Describe the bug On the web platform, when uploading a file to the storage, the debugger pauses and some errors are printed. However, the file is uploaded successfully.

Sample code

As it's on the web, the accurate code that causes error is not known. But by looking at the error logs, it seems subscribing to snapshotEvents is where it happens.

final UploadTask uploadTask = userRef.putData(
  await file.readAsBytes(),
  SettableMetadata(contentType: file.mimeType),
);
uploadTask.snapshotEvents.listen((TaskSnapshot event) async {
  if (event.state == TaskState.running) {
    final double progress = event.bytesTransferred / event.totalBytes;
    EasyLoading.showProgress(
      progress,
      status:
          'Uploading Image...\n${(progress * 100).toStringAsFixed(0)}% Completed',
    );
  }
});

await uploadTask.whenComplete(() => null);

Expected behavior

File should upload without any errors.


Additional context

This is only happening on web after updating from ^10.3.2 to ^10.3.3

Storage Upload Error Logs ```logs TypeError: Cannot read properties of undefined (reading 'STATE_CHANGED') at startListen (http://localhost:60869/packages/firebase_storage_web/src/interop/storage.dart.lib.js:561:97) at Object._runGuarded (http://localhost:60869/dart_sdk.js:40843:7) at [_subscribe] (http://localhost:60869/dart_sdk.js:34405:17) at [_createSubscription] (http://localhost:60869/dart_sdk.js:33673:46) at _BroadcastStream.new.listen (http://localhost:60869/dart_sdk.js:33638:53) at new _ForwardingStreamSubscription.new (http://localhost:60869/dart_sdk.js:38261:55) at [_createSubscription] (http://localhost:60869/dart_sdk.js:38177:16) at _MapStream.new.listen (http://localhost:60869/dart_sdk.js:38174:41) at [_listenToStream] (http://localhost:60869/packages/async/src/stream_group.dart.lib.js:225:35) at [_onListen] (http://localhost:60869/packages/async/src/stream_group.dart.lib.js:168:70) at Object._runGuarded (http://localhost:60869/dart_sdk.js:40843:7) at [_subscribe] (http://localhost:60869/dart_sdk.js:34405:17) at [_createSubscription] (http://localhost:60869/dart_sdk.js:33673:46) at _BroadcastStream.new.listen (http://localhost:60869/dart_sdk.js:33638:53) at new _ForwardingStreamSubscription.new (http://localhost:60869/dart_sdk.js:38261:55) at [_createSubscription] (http://localhost:60869/dart_sdk.js:38177:16) at _HandleErrorStream.new.listen (http://localhost:60869/dart_sdk.js:38174:41) at new _ForwardingStreamSubscription.new (http://localhost:60869/dart_sdk.js:38261:55) at [_createSubscription] (http://localhost:60869/dart_sdk.js:38177:16) at _MapStream.new.listen (http://localhost:60869/dart_sdk.js:38174:41) at uploadImageToFirebase (http://localhost:60869/packages/whats_that_anime/pages/HomePage/functions/upload_image_to_firebase.dart.lib.js:46:35) at uploadImageToFirebase.next () at http://localhost:60869/dart_sdk.js:40641:33 at _RootZone.runUnary (http://localhost:60869/dart_sdk.js:40511:59) at _FutureListener.thenAwait.handleValue (http://localhost:60869/dart_sdk.js:35438:29) at handleValueCallback (http://localhost:60869/dart_sdk.js:35999:49) at _Future._propagateToListeners (http://localhost:60869/dart_sdk.js:36037:17) at [_complete] (http://localhost:60869/dart_sdk.js:35864:25) at Object._cancelAndValue (http://localhost:60869/dart_sdk.js:40905:24) at http://localhost:60869/dart_sdk.js:21397:17 at Object._checkAndCall (http://localhost:60869/dart_sdk.js:5279:16) at Object.dcall (http://localhost:60869/dart_sdk.js:5284:17) at FileReader. (http://localhost:60869/dart_sdk.js:108960:106) ```

But surprisingly, the debugger pauses for exception in image

image


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.22622.436], locale en-IN) Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.3) [√] Android Studio (version 2021.2) [√] VS Code (version 1.69.2) [√] Connected device (3 available) [√] HTTP Host Availability • No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.17.6 Flutter SDK 3.0.5 whats_that_anime 2.1.0+4 dependencies: - cached_network_image 3.2.1 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - chewie 1.3.4 [cupertino_icons flutter provider video_player wakelock] - cloud_firestore 3.4.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cupertino_icons 1.0.5 - desktop_drop 0.3.3 [flutter flutter_web_plugins cross_file] - dotted_border 2.0.0+2 [flutter path_drawing] - firebase_auth 3.5.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.20.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_storage 10.3.3 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_easyloading 3.0.5 [flutter flutter_spinkit] - flutter_native_splash 2.2.5 [args flutter flutter_web_plugins image js lint meta path universal_io xml yaml] - get_storage 2.0.3 [flutter get path_provider] - http 0.13.4 [async http_parser meta path] - image_picker 0.8.5+3 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - internet_connection_checker_plus 1.0.1 [flutter http] - motion_toast 2.3.0 [flutter] - package_info_plus 1.4.3 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - paginate_firestore 1.0.3 [flutter bloc flutter_bloc cloud_firestore provider] - pasteboard 0.2.0 [flutter flutter_web_plugins js] - url_launcher 6.1.5 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - video_player 2.4.5 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] dev dependencies: - change_app_package_name 1.1.0 - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - icons_launcher 1.2.1 [args image path universal_io yaml] transitive dependencies: - archive 3.3.1 [crypto path] - args 2.3.1 - async 2.8.2 [collection meta] - bloc 7.2.1 [meta] - boolean_selector 2.1.0 [source_span string_scanner] - cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.1 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.2.0 - charcode 1.3.1 - clock 1.1.0 - cloud_firestore_platform_interface 5.7.0 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.8.0 [cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.16.0 - cross_file 0.3.3+1 [js meta] - crypto 3.0.2 [typed_data] - csslib 0.17.2 [source_span] - fake_async 1.3.0 [clock collection] - ffi 2.0.1 - file 6.1.2 [meta path] - firebase_auth_platform_interface 6.4.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 4.1.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.5.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 1.7.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.1.12 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.3.1 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_bloc 7.3.3 [flutter bloc provider] - flutter_blurhash 0.7.0 [flutter] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_plugin_android_lifecycle 2.0.7 [flutter] - flutter_spinkit 5.1.0 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - get 4.6.5 [flutter] - html 0.15.0 [csslib source_span] - http_parser 4.0.1 [collection source_span string_scanner typed_data] - image 3.2.0 [archive meta xml] - image_picker_android 0.8.5+1 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.8 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.5+6 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.5.0 [cross_file flutter http plugin_platform_interface] - intl 0.17.0 [clock path] - js 0.6.4 - lint 1.8.2 - lints 2.0.0 - matcher 0.12.11 [stack_trace] - material_color_utilities 0.1.4 - meta 1.7.0 - nested 1.0.0 [flutter] - octo_image 1.0.2 [flutter flutter_blurhash] - package_info_plus_linux 1.0.5 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.3.0 [flutter] - package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.5 [flutter flutter_web_plugins http meta package_info_plus_platform_interface] - package_info_plus_windows 2.0.0 [package_info_plus_platform_interface ffi flutter win32] - path 1.8.1 - path_drawing 1.0.0 [vector_math meta path_parsing flutter] - path_parsing 1.0.0 [vector_math meta] - path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - path_provider_android 2.0.16 [flutter path_provider_platform_interface] - path_provider_ios 2.0.10 [flutter path_provider_platform_interface] - path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.6 [flutter path_provider_platform_interface] - path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.0 [ffi flutter path path_provider_platform_interface win32] - pedantic 1.11.1 - petitparser 5.0.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.2 [meta] - process 4.2.4 [file path platform] - provider 6.0.3 [collection flutter nested] - rxdart 0.27.5 - sky_engine 0.0.99 - source_span 1.8.2 [collection path term_glyph] - sqflite 2.0.3 [flutter sqflite_common path] - sqflite_common 2.2.1+1 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0+2 - term_glyph 1.2.0 - test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.1 [collection] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher_android 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.0 [flutter plugin_platform_interface] - url_launcher_web 2.0.12 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface] - uuid 3.0.6 [crypto] - vector_math 2.1.2 - video_player_android 2.3.8 [flutter video_player_platform_interface] - video_player_avfoundation 2.3.5 [flutter video_player_platform_interface] - video_player_platform_interface 5.1.3 [flutter plugin_platform_interface] - video_player_web 2.0.12 [flutter flutter_web_plugins video_player_platform_interface] - wakelock 0.6.2 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] - wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.3.0 [flutter meta] - wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.2.0 [flutter wakelock_platform_interface win32] - win32 2.7.0 [ffi] - xdg_directories 0.2.0+1 [meta path process] - xml 6.1.0 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

Lyokone commented 2 years ago

Hello, Thanks for the report, I can reproduce on the demo app