d-markey / squadron

Multithreading and worker thread pool for Dart / Flutter, to offload CPU-bound and heavy I/O tasks to Isolate or Web Worker threads.
https://pub.dev/packages/squadron
MIT License
79 stars 0 forks source link

Error: Expected a value of type 'String', but got one of type '(Map<dynamic, dynamic>) => void' #17

Closed VladimirCores closed 1 year ago

VladimirCores commented 1 year ago

Just want to ask maybe you can give me a hint on this error? Running on web target in Chromium: Version 110.0.5481.77 (Official Build) Fedora Project (64-bit)

Error: Expected a value of type 'String', but got one of type '(Map<dynamic, dynamic>) => void'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 288:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 121:3       castError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 529:12  cast
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 704:17                as
packages/squadron/src/browser/_channel.dart 277:22                                openChannel
packages/squadron/src/channel.dart 54:7                                           open
packages/squadron/src/worker.dart 207:32                                          start
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 123:5                _async
packages/squadron/src/worker.dart 202:24                                          start
packages/squadron/src/worker.dart 115:23                                          send
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 123:5                _async
packages/squadron/src/worker.dart 99:20                                           send
packages/frame/services/vk_service.dart 191:26                                    init
packages/frame/main.dart 32:20                                                    main$
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 123:5                _async
packages/frame/main.dart 29:10                                                    main$
web_entrypoint.dart 24:31                                                         <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 367:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 372:39  dcall
lib/ui/initialization.dart 77:15                                                  <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50                <fn>
dart-sdk/lib/async/zone.dart 1660:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 147:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 784:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 813:13                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 584:5                                         [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 657:7                                         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 177:15               <fn>

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.8.0-15.0.pre.1, on Fedora Linux 37 (Workstation Edition) 6.1.12-200.fc37.x86_64, locale
    en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.75.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Squadron: ^4.3.3

d-markey commented 1 year ago

Looks like you're passing a void Function(Map) as the worker's entry point.

image

This won't work for Web workers, you must pass a String with the URL to the worker's compiled .dart.js file.

d-markey commented 1 year ago

I assume it works now, closing this issue. Feel free to reopen if you need further help.

VladimirCores commented 1 year ago

@d-markey, read your answer, will try the way suggested in docs, I just do not have time to try it right now (reads web target is not very important). BTW: Android version works perfect! Thanks for the library : )