Flutterfire: [firebase_storage] StorageUploadTask's event stream is never closed

Created on 8 Mar 2020  Â·  6Comments  Â·  Source: FirebaseExtended/flutterfire

Describe the bug
The stream of the StorageUploadTask's events property is not closed; Therefore, awaiting events.last will never return.

To Reproduce

Code for reproduction:

StorageReference storageReference = FirebaseStorage.instance.ref();
StorageUploadTask uploadTask = storageReference.putFile(file);
await uploadTask.events.last;

Expected behavior
The stream is properly closed when the file is successfully uploaded.

Additional context
I dug a bit into the code of the StorageUploadTask implementation and it seems that the StreamController<StorageTaskEvent> _controller is never closed. Therefore, I changed the implementation locally on my system by closing _controller when a StorageTaskEvent with a StorageTaskEventType of StorageTaskEventType.success occurred. Closing the controller had the effect that the await events.last; call returned the moment the file was successfully uploaded. I think the described fix might be related to #1314

flutter doctor -v:

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale en-DE)
    • Flutter version 1.12.13+hotfix.8 at /Users/jenshorstmann/Development/flutter
    • Framework revision 0b8abb4724 (4 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/jenshorstmann/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[!] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

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

[✓] Connected device (1 available)
    • iPhone 11 Pro • 2F1C2C71-5CDA-4630-A540-66FD1496D425 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

pubspec.yaml

name: project_name
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.2.2 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2
  google_fonts: ^0.3.2
  font_awesome_flutter: ^8.5.0
  flutter_launcher_icons: ^0.7.4
  url_launcher: ^5.4.1
  flutter_bloc: ^3.2.0
  firebase_auth: ^0.15.4
  google_sign_in: ^4.1.1
  intl: ^0.16.1
  firebase_core: ^0.4.3+3
  timeago: ^2.0.26
  uuid: ^2.0.4
  cloud_firestore: ^0.13.4+1
  image_picker: ^0.6.3+4

Log

flutterRunLogFile.txt

customer storage bug

All 6 comments

Same!!!

Hi @JensHor
can you please provide your flutter run --verbose
and your pubspec.yaml
Thank you

I added the parts of the pubspec.yaml which I think are important. I also sent theflutter run --verbose log to [email protected]

Hi @JensHor
I have no way to retrieve your logs,
could you please paste it in a comment or attach as txt file
thank you

Alright. Attached the logfile to the post.

I have similar kind of issue when using firebase_storage
I have added my GoogleService-Info.plist to ios/Runner from Xcode and on my main.dart i have added
await Firebase.initializeApp();, cloud_firestore: ^0.14.0+2 works good i am able to CRUD data but when using fireStore to upload files the ios app crashes the only thing that comes in terminal when run on verbose mode is:
[+123976 ms] Service protocol connection closed. [ +1 ms] Lost connection to device. [ +35 ms] DevFS: Deleting filesystem on the device (file:///Users/Me/Library/Developer/CoreSimulator/Devices/12E19722-CC83-452B-B263-EF624D069BED/dat a/Containers/Data/Application/BC48EA57-B913-4281-9628-59C783B0FE77/tmp/app28vRsI/app/) [ +258 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed [ +4 ms] "flutter run" took 223,298ms. [ +271 ms] ensureAnalyticsSent: 264ms [ +2 ms] Running shutdown hooks [ ] Shutdown hook priority 4 [ +7 ms] Shutdown hooks complete [ +2 ms] exiting with code 0
i have gone further adding CFBundleURLSchemes with my REVERSED_CLIENT_ID but that did not make any difference
the firebase packages i have on my pubspec are:
firebase_core: ^0.5.0 cloud_firestore: ^0.14.0+2 firebase_storage: ^4.0.0 firebase_messaging: ^7.0.0
this only happens on ios android works fine

Thanks in advance

Was this page helpful?
0 / 5 - 0 ratings