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.68k stars 3.97k forks source link

🐛 [cloud_firestore] [__NSCFString setStreamHandler:]: unrecognized selector sent to instance 0x280d27d40 -[FLTFirebaseFirestorePlugin cleanupWithCompletion:] #6155

Closed otopba closed 4 months ago

otopba commented 3 years ago

Bug report

I have bug reports in my crashlytics:

Fatal Exception: NSInvalidArgumentException
-[__NSCFString setStreamHandler:]: unrecognized selector sent to instance 0x280d27d40
0
CoreFoundation
__exceptionPreprocess
1
libobjc.A.dylib
objc_exception_throw
2
CoreFoundation
-[NSOrderedSet initWithSet:copyItems:]
3
CoreFoundation
___forwarding___
4
CoreFoundation
_CF_forwarding_prep_0
5
Runner
FLTFirebaseFirestorePlugin.m - Line 122
-[FLTFirebaseFirestorePlugin cleanupWithCompletion:] + 122
6
CoreFoundation
__NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__
7
CoreFoundation
-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]
8
Flutter
(Missing)
9
workmanager
(Missing)
10
workmanager
(Missing)
11
workmanager
(Missing)
12
Flutter
(Missing)
13
Flutter
(Missing)
14
Flutter
(Missing)
15
CoreFoundation
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
16
CoreFoundation
__CFRunLoopDoTimer
17
CoreFoundation
__CFRunLoopDoTimers
18
CoreFoundation
__CFRunLoopRun
19
CoreFoundation
CFRunLoopRunSpecific
20
GraphicsServices
GSEventRunModal
21
UIKitCore
-[UIApplication _run]
22
UIKitCore
UIApplicationMain
23
Runner
AppDelegate.swift - Line 7
main + 7
24
libdyld.dylib
start

image

markusaksli-nc commented 3 years ago

Hi @otopba Could you please provide your flutter doctor -v and flutter pub deps -- --style=compact? Do you know what code triggers this or what iOS versions it happens on? Thank you

otopba commented 3 years ago

Hi @markusaksli-nc My app is very small now that's why I can see only crashes on iPhone 11 Pro iOS 14.5.0

➜  client git:(master) flutter doctor -v
[✓] Flutter (Channel dev, 2.3.0-1.0.pre, on macOS 11.3 20E232 darwin-x64, locale en-RU)
    • Flutter version 2.3.0-1.0.pre at /Users/yuriy.dorofeev/it/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d97f41caed (2 weeks ago), 2021-04-30 12:35:21 -0700
    • Engine revision e7939e091e
    • Dart version 2.14.0 (build 2.14.0-48.0.dev)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/yuriy.dorofeev/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7351085/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.2)
    • Android Studio at /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7351085/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.8+10-b944.6916264)

[✓] Android Studio (version 4.2)
    • Android Studio at /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7351085/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.8+10-b944.6916264)

[✓] Android Studio (version 4.2)
    • Android Studio at /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7322048/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.8+10-b944.6916264)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.1)
    • IntelliJ at /Users/yuriy.dorofeev/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 211.7233

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.1)
    • IntelliJ at /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7142.45/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 211.7179

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
    • IntelliJ at /Users/yuriy.dorofeev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.6693.111/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 211.7179

[✓] VS Code (version 1.56.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • IN2010 (mobile)  • 1e4aaf15         • android-arm64  • Android 11 (API 30)
    • COL L29 (mobile) • CLCDU18703001438 • android-arm64  • Android 10 (API 29)
    • Chrome (web)     • chrome           • web-javascript • Google Chrome 90.0.4430.212

! Doctor found issues in 1 category.
➜  client git:(master) flutter pub deps -- --style=compact
Dart SDK 2.14.0-48.0.dev
Flutter SDK 2.3.0-1.0.pre
word_daily 0.1.11+84

dependencies:
- amplitude_flutter 3.1.0 [flutter]
- another_flushbar 1.10.22 [pedantic flutter]
- async 2.6.1 [meta collection]
- built_value 8.0.6 [built_collection collection fixnum]
- cached_network_image 3.0.0 [flutter flutter_cache_manager octo_image]
- cloud_firestore 2.1.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta]
- cloud_functions 1.0.7 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter]
- cupertino_icons 1.0.3
- device_info 2.0.0 [flutter device_info_platform_interface]
- firebase_analytics 8.0.4 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta]
- firebase_auth 1.1.4 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 1.1.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 2.0.3 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_dynamic_links 2.0.3 [firebase_core flutter]
- firebase_messaging 9.1.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_remote_config 0.6.0 [flutter firebase_core]
- firebase_storage 8.0.6 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_email_sender 5.0.0 [flutter]
- flutter_inapp_purchase 5.0.1 [http meta flutter platform]
- flutter_local_notifications 5.0.0+4 [flutter flutter_local_notifications_platform_interface platform timezone]
- flutter_native_timezone 1.0.10 [flutter]
- flutter_phoenix 1.0.0 [flutter]
- flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml]
- google_sign_in 5.0.3 [google_sign_in_platform_interface google_sign_in_web flutter meta]
- horizontal_blocked_scroll_physics 3.0.0 [flutter pedantic]
- intl 0.17.1-nullsafety.3 [clock path]
- intl_translation 0.17.10+1 [analyzer args dart_style intl path petitparser]
- launch_options 0.0.1 [flutter]
- mime 1.0.0
- optimist_dev_common 1.6.2 [flutter http intl share json_api built_value f_logs strings]
- package_info 2.0.0 [flutter]
- permission_handler 7.1.0 [flutter meta permission_handler_platform_interface]
- provider 5.0.0 [collection flutter nested]
- pull_to_refresh 2.0.0 [flutter]
- scroll_to_index 2.0.0 [flutter]
- shake 1.0.0 [sensors flutter]
- share 2.0.1 [meta mime flutter]
- shared_preferences 2.0.5 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- sign_in_with_apple 3.0.0 [flutter meta]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- url_launcher_web 0.1.5+3 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- video_player 2.1.1 [meta video_player_platform_interface video_player_web flutter flutter_test]
- visibility_detector 0.2.0 [flutter]
- vk_bridge 1.3.1 [js built_value built_collection rxdart meta]
- wakelock 0.5.2 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows]
- workmanager 0.4.0 [flutter]

dev dependencies:
- build_runner 2.0.3 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- built_value_generator 8.0.6 [analyzer build build_config built_collection built_value source_gen quiver]
- cloud_firestore_mocks 0.9.0 [flutter cloud_firestore cloud_firestore_platform_interface collection plugin_platform_interface quiver]
- flutter_launcher_icons 0.9.0 [args image path yaml]
- flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math]
- flutter_native_splash 1.1.8+4 [image meta path xml yaml universal_io]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]
- mockito 5.0.7 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api]

dependency overrides:
- analyzer 1.5.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml pedantic]
- args 2.1.0
- async 2.6.1 [meta collection]
- cloud_firestore 2.1.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta]
- cloud_firestore_platform_interface 5.0.1 [collection firebase_core flutter meta plugin_platform_interface]
- dart_style 2.0.1 [analyzer args path pub_semver source_span]
- firebase_core 1.1.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- http 0.13.3 [async http_parser meta path pedantic]
- http_parser 4.0.0 [charcode collection source_span string_scanner typed_data]
- intl 0.17.1-nullsafety.3 [clock path]
- path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- petitparser 4.1.0 [meta]
- plugin_platform_interface 2.0.0 [meta]

transitive dependencies:
- _fe_analyzer_shared 21.0.0 [meta]
- archive 3.1.2 [crypto path]
- boolean_selector 2.1.0 [source_span string_scanner]
- build 2.0.1 [analyzer async convert crypto glob logging meta path]
- build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml]
- build_daemon 3.0.0 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 2.0.1 [analyzer build crypto graphs logging path package_config pool pub_semver stream_transform]
- build_runner_core 7.0.0 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pedantic pool timing watcher yaml]
- built_collection 5.0.0
- characters 1.1.0
- charcode 1.2.0
- checked_yaml 2.0.1 [json_annotation source_span yaml]
- cli_util 0.3.0 [meta path]
- clock 1.1.0
- cloud_firestore_web 2.0.1 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- cloud_functions_platform_interface 5.0.4 [firebase_core flutter meta plugin_platform_interface]
- cloud_functions_web 4.0.6 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- code_builder 4.0.0 [built_collection built_value collection matcher meta]
- collection 1.15.0
- convert 3.0.0 [typed_data]
- crypto 3.0.1 [collection typed_data]
- device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- f_logs 2.0.0 [flutter sembast path_provider intl xxtea meta path stack_trace]
- fake_async 1.2.0 [clock collection]
- ffi 1.0.0
- file 6.1.0 [meta path]
- firebase 9.0.1 [http http_parser js]
- firebase_analytics_platform_interface 2.0.1 [flutter meta]
- firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta]
- firebase_auth_platform_interface 4.2.2 [firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 1.1.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface]
- firebase_core_web 1.0.3 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_crashlytics_platform_interface 3.0.3 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 2.1.4 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 1.0.7 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- firebase_storage_platform_interface 2.0.4 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 1.0.6 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta]
- fixnum 1.0.0
- flutter_blurhash 0.6.0 [flutter meta pedantic]
- flutter_cache_manager 3.0.2 [clock collection file flutter http image path path_provider pedantic rxdart sqflite uuid]
- flutter_local_notifications_platform_interface 3.0.0 [flutter plugin_platform_interface]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- frontend_server_client 2.1.0 [async path]
- glob 2.0.1 [async collection file path pedantic string_scanner]
- google_sign_in_platform_interface 2.0.1 [flutter meta quiver]
- google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- graphs 2.0.0
- http_multi_server 3.0.1 [async]
- image 3.0.2 [archive meta xml]
- io 1.0.0 [meta path string_scanner]
- js 0.6.3
- json_annotation 4.0.1
- json_api 4.3.0 [http http_parser]
- lists 1.0.0 [meta]
- logging 1.0.1
- matcher 0.12.10 [stack_trace]
- meta 1.3.0
- nested 1.0.0 [flutter]
- octo_image 1.0.0+1 [flutter flutter_blurhash]
- package_config 2.0.0 [path]
- path 1.8.0
- path_drawing 0.5.1 [vector_math meta path_parsing flutter]
- path_parsing 0.2.1 [vector_math meta]
- path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 2.0.0 [flutter]
- path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface]
- path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.11.0
- permission_handler_platform_interface 3.3.0 [flutter meta plugin_platform_interface]
- platform 3.0.0
- pool 1.5.0 [async stack_trace]
- process 4.2.1 [file path platform]
- pub_semver 2.0.0 [collection]
- pubspec_parse 1.0.0 [checked_yaml collection json_annotation pub_semver yaml]
- quiver 3.0.1 [matcher]
- rxdart 0.27.0
- sembast 3.0.2 [meta path synchronized pedantic]
- sensors 2.0.0 [flutter]
- shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows]
- shelf 1.1.4 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- source_gen 1.0.0 [analyzer async build dart_style glob meta path pedantic source_span]
- source_span 1.8.1 [collection path term_glyph]
- sqflite 2.0.0+3 [flutter sqflite_common path]
- sqflite_common 2.0.0+2 [synchronized path meta]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- stream_transform 2.0.0
- string_scanner 1.1.0 [charcode source_span]
- strings 0.2.1 [characters unicode]
- synchronized 3.0.0
- term_glyph 1.2.0
- test_api 0.3.0 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timezone 0.7.0 [path]
- timing 1.0.0 [json_annotation]
- typed_data 1.3.0 [collection]
- unicode 0.3.0 [lists]
- universal_io 2.0.4 [collection crypto meta typed_data]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_windows 0.0.1+3 [flutter]
- uuid 3.0.4 [crypto]
- vector_math 2.1.0
- video_player_platform_interface 4.1.0 [flutter meta flutter_test]
- video_player_web 2.0.0 [flutter flutter_web_plugins meta video_player_platform_interface]
- wakelock_macos 0.1.0+1 [flutter flutter_web_plugins wakelock_platform_interface]
- wakelock_platform_interface 0.2.1+1 [flutter meta]
- wakelock_web 0.2.0+1 [flutter flutter_web_plugins js wakelock_platform_interface]
- wakelock_windows 0.1.0 [flutter wakelock_platform_interface win32]
- watcher 1.0.0 [async path pedantic]
- web_socket_channel 2.1.0 [async crypto stream_channel]
- win32 2.0.5 [ffi]
- xdg_directories 0.2.0 [meta path process]
- xml 5.1.0 [collection meta petitparser]
- xxtea 2.1.0
- yaml 3.1.0 [collection source_span string_scanner]
markusaksli-nc commented 3 years ago

Do you have a specific query or line of code that triggers this crash?

otopba commented 3 years ago

I can't say that there is something special. Perhaps there are some problems with race conditions: at some point, I try to change the same document from several places

ItzNotABug commented 3 years ago

@otopba I had this same crash when I tried to use cloud_firestore in a separate Isolate. The crash would occur after the Isolate would be killed via the IsolateHandler.kill().

The reason would be that there is only one instance of Cloud Firestore from the native side for setting the setStreamHandler & when a new instance is created in a separate isolate, it binds to the existing one.

So when the isolate is killed off, the native side tries to remove the Stream Handler with that same instance but it doesn't recognise this new one & crashes the app.

Are you using anything like that?

otopba commented 3 years ago

@ItzNotABug Whoa! It looks like this is just my problem. Yes, I use periodic tasks from the workmanager package, they run in a separate isolate. Is there some way to get around this problem?

ItzNotABug commented 3 years ago

@otopba I ended up with a hacky solution, & not the great one though. In the FLTFirebaseFirestorePlugin file, there is a detachFromEngineForRegistrar:() method which has this [self cleanupWithCompletion:nil]; method call.

I simply wrapped it in a try / catch block like:

- (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
    @try {
        [self cleanupWithCompletion:nil];
    }
    @catch (NSException * e) {
        NSLog(@"Hmmm, this is a bad soln");
    }
    @finally {}
}

Now, it doesn't detach from the main & only FlutterEngine & the streamHandler is not set to null if it doesn't recognise the instance which we know is coming from the separate isolate.

This is really not an ideal solution. The only issue you may face while development is that if the isolate is spawned & not killed off, every attempt to Hot Restart will kill the app on iOS completely & you'd have to re-install the app. Hot Reload will work but not always make relevant changes. As long as you properly dispose off the separate isolates, it works fine. Also, make sure you call await Firebase.initializeApp inside the other Isolate before running any Firebase tasks.

I think Flutter Team should take a look at this & either provide a solution to this or let us know if this approach can be changed in a better way. Thanks.

otopba commented 3 years ago

@ItzNotABug Thank you! Ufff. Really not the best solution. @markusaksli-nc, please pay attention to the message above

sanekyy commented 3 years ago

Same issue:(

ItzNotABug commented 3 years ago

We have any update on this? It's not feasible to alter the file on every pod update / install.

ened commented 3 years ago

@ItzNotABug do you have a repro case in a GH repository? I'm happy to take a look.

adrianorazzini commented 2 years ago

Hi guys Any update on this? I'm facing exactly the same issue and the solution from @ItzNotABug worked well, but as he also mentioned, this is not ideal solution.

adrianorazzini commented 2 years ago

Hi everyone! Just to share my findings here: I was facing the same issues as described in this issue #6155 and I was trying to use the @ItzNotABug suggestion temporarily. It "solved" the crash, but kept not working. Then I came up with the following conclusion: If I am running a background task, that will do whatever it should do (in my case read some firestore data and schedule notifications), and finish its job, why I was trying to use Stream??? It does not make sense to use Snapshot Stream in this case and that's why setStreamHandler is failing. I refactored my code to get data using Future/Await instead of listening the Stream and then everything worked as expected.

NOTE: If you are using Flutter Workmanager, don't forget to use await in your routines to make sure the background execution will wait your execution before terminating.

Limvunhoy commented 2 years ago

Is this problem solved?

Afur commented 1 year ago

Any update?

TarekkMA commented 4 months ago

Hi @otopba ,

Thank you for your reprot! Since this issue was opened, the implementation details have changed significantly. If you feel that this issue is still relevant, please feel free to open a new issue with updated context. We appreciate your understanding and support.