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

Running example code and clicking "fetch remote data" leads to multiple "Unhandled Exception: Bad state: Stream has already been listened to." errors #69

Closed
rainerlonau opened this issue Nov 30, 2021 · 1 comment

Comments

@rainerlonau
Copy link

rainerlonau commented Nov 30, 2021

ERRORS

E/flutter (23385): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Stream has already been listened to.
E/flutter (23385): #0      _StreamController._subscribe (dart:async/stream_controller.dart:635:7)
E/flutter (23385): #1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:786:19)
E/flutter (23385): #2      _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
E/flutter (23385): #3      _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:89:31)
E/flutter (23385): #4      _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:1027:33)
E/flutter (23385): #5      _StreamIterator.moveNext (dart:async/stream_impl.dart:1003:12)
E/flutter (23385): #6      QuickJsRuntime2.dispatch (package:flutter_js/quickjs/quickjs_runtime2.dart)
E/flutter (23385): #7      QuickJsRuntime2.executePendingJob (package:flutter_js/quickjs/quickjs_runtime2.dart:217:10)
E/flutter (23385): #8      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:113:20)
E/flutter (23385): #9      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:112:27)
E/flutter (23385): #10     HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:124:64)
E/flutter (23385): #11     new Future.delayed.<anonymous closure> (dart:async/future.dart:315:39)
E/flutter (23385): #12     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (23385): #13     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #14     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (23385): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (23385): #16     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (23385): #17     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #18     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186:23)
E/flutter (23385): #19     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (23385): #20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (23385): #21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (23385): #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23385): 
E/flutter (23385): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Stream has already been listened to.
E/flutter (23385): #0      _StreamController._subscribe (dart:async/stream_controller.dart:635:7)
E/flutter (23385): #1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:786:19)
E/flutter (23385): #2      _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
E/flutter (23385): #3      _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:89:31)
E/flutter (23385): #4      _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:1027:33)
E/flutter (23385): #5      _StreamIterator.moveNext (dart:async/stream_impl.dart:1003:12)
E/flutter (23385): #6      QuickJsRuntime2.dispatch (package:flutter_js/quickjs/quickjs_runtime2.dart)
E/flutter (23385): #7      QuickJsRuntime2.executePendingJob (package:flutter_js/quickjs/quickjs_runtime2.dart:217:10)
E/flutter (23385): #8      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:113:20)
E/flutter (23385): #9      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:112:27)
E/flutter (23385): #10     HandlePromises._doHandlePromise.<anonymous closure>.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:116:68)
E/flutter (23385): #11     new Future.delayed.<anonymous closure> (dart:async/future.dart:315:39)
E/flutter (23385): #12     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (23385): #13     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #14     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (23385): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (23385): #16     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (23385): #17     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #18     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186:23)
E/flutter (23385): #19     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (23385): #20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (23385): #21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (23385): #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23385): 
I/chatty  (23385): uid=10090(io.abner.flutter_js_example) 1.ui identical 2 lines
E/flutter (23385): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Stream has already been listened to.
E/flutter (23385): #0      _StreamController._subscribe (dart:async/stream_controller.dart:635:7)
E/flutter (23385): #1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:786:19)
E/flutter (23385): #2      _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
E/flutter (23385): #3      _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:89:31)
E/flutter (23385): #4      _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:1027:33)
E/flutter (23385): #5      _StreamIterator.moveNext (dart:async/stream_impl.dart:1003:12)
E/flutter (23385): #6      QuickJsRuntime2.dispatch (package:flutter_js/quickjs/quickjs_runtime2.dart)
E/flutter (23385): #7      QuickJsRuntime2.executePendingJob (package:flutter_js/quickjs/quickjs_runtime2.dart:217:10)
E/flutter (23385): #8      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:113:20)
E/flutter (23385): #9      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:112:27)
E/flutter (23385): #10     HandlePromises._doHandlePromise.<anonymous closure>.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:116:68)
E/flutter (23385): #11     new Future.delayed.<anonymous closure> (dart:async/future.dart:315:39)
E/flutter (23385): #12     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (23385): #13     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #14     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (23385): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (23385): #16     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (23385): #17     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #18     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186:23)
E/flutter (23385): #19     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (23385): #20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (23385): #21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (23385): #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23385): 
E/flutter (23385): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Stream has already been listened to.
E/flutter (23385): #0      _StreamController._subscribe (dart:async/stream_controller.dart:635:7)
E/flutter (23385): #1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:786:19)
E/flutter (23385): #2      _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
E/flutter (23385): #3      _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:89:31)
E/flutter (23385): #4      _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:1027:33)
E/flutter (23385): #5      _StreamIterator.moveNext (dart:async/stream_impl.dart:1003:12)
E/flutter (23385): #6      QuickJsRuntime2.dispatch (package:flutter_js/quickjs/quickjs_runtime2.dart)
E/flutter (23385): #7      QuickJsRuntime2.executePendingJob (package:flutter_js/quickjs/quickjs_runtime2.dart:217:10)
E/flutter (23385): #8      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:113:20)
E/flutter (23385): #9      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:112:27)
E/flutter (23385): #10     HandlePromises._doHandlePromise.<anonymous closure>.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:116:68)
E/flutter (23385): #11     new Future.delayed.<anonymous closure> (dart:async/future.dart:315:39)
E/flutter (23385): #12     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (23385): #13     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #14     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (23385): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (23385): #16     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (23385): #17     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #18     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186:23)
E/flutter (23385): #19     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (23385): #20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (23385): #21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (23385): #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23385): 
I/chatty  (23385): uid=10090(io.abner.flutter_js_example) 1.ui identical 4 lines
E/flutter (23385): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Stream has already been listened to.
E/flutter (23385): #0      _StreamController._subscribe (dart:async/stream_controller.dart:635:7)
E/flutter (23385): #1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:786:19)
E/flutter (23385): #2      _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
E/flutter (23385): #3      _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:89:31)
E/flutter (23385): #4      _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:1027:33)
E/flutter (23385): #5      _StreamIterator.moveNext (dart:async/stream_impl.dart:1003:12)
E/flutter (23385): #6      QuickJsRuntime2.dispatch (package:flutter_js/quickjs/quickjs_runtime2.dart)
E/flutter (23385): #7      QuickJsRuntime2.executePendingJob (package:flutter_js/quickjs/quickjs_runtime2.dart:217:10)
E/flutter (23385): #8      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:113:20)
E/flutter (23385): #9      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:112:27)
E/flutter (23385): #10     HandlePromises._doHandlePromise.<anonymous closure>.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:116:68)
E/flutter (23385): #11     new Future.delayed.<anonymous closure> (dart:async/future.dart:315:39)
E/flutter (23385): #12     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (23385): #13     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #14     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (23385): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (23385): #16     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (23385): #17     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #18     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186:23)
E/flutter (23385): #19     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (23385): #20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (23385): #21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (23385): #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23385): 
E/flutter (23385): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Stream has already been listened to.
E/flutter (23385): #0      _StreamController._subscribe (dart:async/stream_controller.dart:635:7)
E/flutter (23385): #1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:786:19)
E/flutter (23385): #2      _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
E/flutter (23385): #3      _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:89:31)
E/flutter (23385): #4      _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:1027:33)
E/flutter (23385): #5      _StreamIterator.moveNext (dart:async/stream_impl.dart:1003:12)
E/flutter (23385): #6      QuickJsRuntime2.dispatch (package:flutter_js/quickjs/quickjs_runtime2.dart)
E/flutter (23385): #7      QuickJsRuntime2.executePendingJob (package:flutter_js/quickjs/quickjs_runtime2.dart:217:10)
E/flutter (23385): #8      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:113:20)
E/flutter (23385): #9      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:112:27)
E/flutter (23385): #10     HandlePromises._doHandlePromise.<anonymous closure>.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:116:68)
E/flutter (23385): #11     new Future.delayed.<anonymous closure> (dart:async/future.dart:315:39)
E/flutter (23385): #12     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (23385): #13     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #14     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (23385): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (23385): #16     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (23385): #17     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #18     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186:23)
E/flutter (23385): #19     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (23385): #20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (23385): #21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (23385): #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23385): 
I/chatty  (23385): uid=10090(io.abner.flutter_js_example) 1.ui identical 1 line
E/flutter (23385): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Stream has already been listened to.
E/flutter (23385): #0      _StreamController._subscribe (dart:async/stream_controller.dart:635:7)
E/flutter (23385): #1      _ControllerStream._createSubscription (dart:async/stream_controller.dart:786:19)
E/flutter (23385): #2      _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
E/flutter (23385): #3      _ReceivePortImpl.listen (dart:isolate-patch/isolate_patch.dart:89:31)
E/flutter (23385): #4      _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:1027:33)
E/flutter (23385): #5      _StreamIterator.moveNext (dart:async/stream_impl.dart:1003:12)
E/flutter (23385): #6      QuickJsRuntime2.dispatch (package:flutter_js/quickjs/quickjs_runtime2.dart)
E/flutter (23385): #7      QuickJsRuntime2.executePendingJob (package:flutter_js/quickjs/quickjs_runtime2.dart:217:10)
E/flutter (23385): #8      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:113:20)
E/flutter (23385): #9      HandlePromises._doHandlePromise.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:112:27)
E/flutter (23385): #10     HandlePromises._doHandlePromise.<anonymous closure>.<anonymous closure> (package:flutter_js/extensions/handle_promises.dart:116:68)
E/flutter (23385): #11     new Future.delayed.<anonymous closure> (dart:async/future.dart:315:39)
E/flutter (23385): #12     _rootRun (dart:async/zone.dart:1346:47)
E/flutter (23385): #13     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #14     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (23385): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (23385): #16     _rootRun (dart:async/zone.dart:1354:13)
E/flutter (23385): #17     _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (23385): #18     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1186:23)
E/flutter (23385): #19     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (23385): #20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (23385): #21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (23385): #22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23385): 

flutter doctor -v

[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19043.1348], locale de-DE)
• Flutter version 2.0.6 at C:_Dev\Flutter
• Framework revision 1d9032c7e1 (7 months ago), 2021-04-29 17:37:58 -0700
• Engine revision 05e680e202
• Dart version 2.12.3

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:_Dev\AndroidSDK
• Platform android-30, build-tools 30.0.1
• ANDROID_HOME = C:_Dev\AndroidSDK
• Java binary at: C:_Dev\AndroidStudio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
• Android Studio at C:_Dev\AndroidStudio
• 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.10+0-b96-7249189)

[√] Connected device (3 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45
• Edge (web) • edge • web-javascript • Microsoft Edge 94.0.992.50

• No issues found!

@rainerlonau
Copy link
Author

I got it working now with the JavascriptCore

On Android you could use JavascriptCore as well You just need add an Android dependency implementation "com.github.fast-development.android-js-runtimes:fastdev-jsruntimes-jsc:0.1.3" and pass forceJavascriptCoreOnAndroid: true to the function getJavascriptRuntime.
https://pub.dev/packages/flutter_js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant