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

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

Closed
VladimirCores opened this issue Feb 23, 2023 · 3 comments

Comments

@VladimirCores
Copy link

VladimirCores commented Feb 23, 2023

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
Copy link
Owner

d-markey commented Feb 23, 2023

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
Copy link
Owner

d-markey commented Mar 4, 2023

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

@d-markey d-markey closed this as completed Mar 4, 2023
@VladimirCores
Copy link
Author

@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 : )

d-markey added a commit that referenced this issue Jun 6, 2023
…mize serialization overhead. Replace previous `WorkerRequest` and `WorkerResponse` implementations with extension methods. This may be a breaking change.

- Add `EntryPoint` and `PlatformWorker` typedefs to enforce type safety across runtime platforms. `EntryPoint` and `PlatformWorker` should both resolve to `dynamic` in the IDE. At compile time, they should resolve to the concrete types according to the platform (ie. `String` and `Worker` from `dart:html` for Web platforms, `FutureOr Function(List)` and `Isolate` on native platforms). This should help prevent issues such as #17.
- Provide access to platform worker instance upon initialization. See #20.
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

2 participants