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: [-2, lib/.... ] Refused to execute script #25

Closed rayk closed 9 months ago

rayk commented 11 months ago

Bit of an issue using squadron and squadron build.

Summary: Generated Code will not load, when worker.start() is called, the following error is produced.

Refused to execute script from 'http://localhost:57183/lib/service/live feed/live feed.web.g.dart.js' because its MIME type ('text/html') is not executable, localhost/:1
and strict MIME type checking is enabled.

followed by:

Uncaught (in promise) Error: [-2, "lib/service/live_feed/live_feed.web.g.dart.js: error / [object Event]", "dart-
errors.dart:321
sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 942:28
get current\npackages/squadron/src/worker_exception.dart 17:34
new\packages/squadron/src/browser/_channel.dart 273:21
367:37
<fn>\ndart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
_checkAndCall\ndart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart372:39
dcall\ndart-sdk/lib/html/dart2js/html_dart2js.dart 37236:58
<fn>\n", null, null]
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 942:28
get current
packages/squadron/src/worker exception.dart 17:34
new
packages/squadron/src/browser/_channel.dart 273:21
<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 dart-sdk/lib/html/dart2js/html dart2js.dart 37236:58
Flutter Environment & Dependencies ```bash [✓] Flutter (Channel stable, 3.10.6, on macOS 13.5 22G74 darwin-x64, locale en-AU) • Flutter version 3.10.6 on channel stable at /Users/rayk/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f468f3366c (3 weeks ago), 2023-07-12 15:19:05 -0700 • Engine revision cdbeda788a • Dart version 3.0.6 • DevTools version 2.23.1 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at /Users/rayk/Library/Android/sdk • Platform android-33, build-tools 33.0.1 • Java binary at: /Users/rayk/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10406996/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14E300c • CocoaPods version 1.12.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] IntelliJ IDEA Ultimate Edition (version 2023.2) • IntelliJ at /Users/rayk/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app • Flutter plugin version 75.0.4 • Dart plugin version 232.8660.129 [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-x64 • macOS 13.5 22G74 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.114 [✓] Network resources • All expected network resources are available. • No issues found! ```
Project Dependencies ```yaml packages: _fe_analyzer_shared: dependency: transitive description: name: _fe_analyzer_shared sha256: "405666cd3cf0ee0a48d21ec67e65406aad2c726d9fa58840d3375e7bdcd32a07" url: "https://pub.dev" source: hosted version: "60.0.0" analyzer: dependency: transitive description: name: analyzer sha256: "1952250bd005bacb895a01bf1b4dc00e3ba1c526cf47dca54dfe24979c65f5b3" url: "https://pub.dev" source: hosted version: "5.12.0" analyzer_plugin: dependency: transitive description: name: analyzer_plugin sha256: c1d5f167683de03d5ab6c3b53fc9aeefc5d59476e7810ba7bbddff50c6f4392d url: "https://pub.dev" source: hosted version: "0.11.2" archive: dependency: transitive description: name: archive sha256: "0c8368c9b3f0abbc193b9d6133649a614204b528982bebc7026372d61677ce3a" url: "https://pub.dev" source: hosted version: "3.3.7" args: dependency: transitive description: name: args sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted version: "2.4.2" async: dependency: transitive description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" url: "https://pub.dev" source: hosted version: "2.1.1" build: dependency: transitive description: name: build sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" url: "https://pub.dev" source: hosted version: "2.4.1" build_config: dependency: transitive description: name: build_config sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 url: "https://pub.dev" source: hosted version: "1.1.1" build_daemon: dependency: transitive description: name: build_daemon sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" url: "https://pub.dev" source: hosted version: "4.0.0" build_resolvers: dependency: transitive description: name: build_resolvers sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20" url: "https://pub.dev" source: hosted version: "2.2.1" build_runner: dependency: "direct dev" description: name: build_runner sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b" url: "https://pub.dev" source: hosted version: "2.4.6" build_runner_core: dependency: transitive description: name: build_runner_core sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41" url: "https://pub.dev" source: hosted version: "7.2.10" built_collection: dependency: "direct main" description: name: built_collection sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" url: "https://pub.dev" source: hosted version: "5.1.1" built_value: dependency: "direct main" description: name: built_value sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166" url: "https://pub.dev" source: hosted version: "8.6.1" built_value_generator: dependency: "direct dev" description: name: built_value_generator sha256: "14835d3ee2a0b19ffb263c57d82a3b2a64b0090d6b9d12e3b1646c1ff82a2476" url: "https://pub.dev" source: hosted version: "8.6.1" characters: dependency: transitive description: name: characters sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted version: "1.3.0" chart_sparkline: dependency: "direct main" description: name: chart_sparkline sha256: "10c68b0062056471bd64afccb13cb5bcad6edc087b4f939991094bc68af4d673" url: "https://pub.dev" source: hosted version: "1.0.13" checked_yaml: dependency: transitive description: name: checked_yaml sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff url: "https://pub.dev" source: hosted version: "2.0.3" ci: dependency: transitive description: name: ci sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13" url: "https://pub.dev" source: hosted version: "0.1.0" cli_util: dependency: transitive description: name: cli_util sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7 url: "https://pub.dev" source: hosted version: "0.4.0" clock: dependency: transitive description: name: clock sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf url: "https://pub.dev" source: hosted version: "1.1.1" code_builder: dependency: transitive description: name: code_builder sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189" url: "https://pub.dev" source: hosted version: "4.5.0" collection: dependency: transitive description: name: collection sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted version: "1.17.1" convert: dependency: transitive description: name: convert sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" url: "https://pub.dev" source: hosted version: "3.1.1" crypto: dependency: transitive description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted version: "3.0.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be url: "https://pub.dev" source: hosted version: "1.0.5" custom_lint: dependency: "direct dev" description: name: custom_lint sha256: "3ce36c04d30c60cde295588c6185b3f9800e6c18f6670a7ffdb3d5eab39bb942" url: "https://pub.dev" source: hosted version: "0.4.0" custom_lint_builder: dependency: transitive description: name: custom_lint_builder sha256: "73d09c9848e9f6d5c3e0a1809eac841a8d7ea123d0849feefa040e1ad60b6d06" url: "https://pub.dev" source: hosted version: "0.4.0" custom_lint_core: dependency: transitive description: name: custom_lint_core sha256: "9170d9db2daf774aa2251a3bc98e4ba903c7702ab07aa438bc83bd3c9a0de57f" url: "https://pub.dev" source: hosted version: "0.4.0" dart_style: dependency: transitive description: name: dart_style sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" url: "https://pub.dev" source: hosted version: "2.3.2" equatable: dependency: "direct main" description: name: equatable sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 url: "https://pub.dev" source: hosted version: "2.0.5" fake_async: dependency: transitive description: name: fake_async sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" url: "https://pub.dev" source: hosted version: "1.3.1" faker: dependency: "direct main" description: name: faker sha256: "746e59f91d8b06a389e74cf76e909a05ed69c12691768e2f93557fdf29200fd0" url: "https://pub.dev" source: hosted version: "2.1.0" fast_immutable_collections: dependency: "direct main" description: name: fast_immutable_collections sha256: b4f7d3af6e90a80cf7a3dddd0de3b4a46acb446320795b77b034535c4d267fbe url: "https://pub.dev" source: hosted version: "9.1.5" ffi: dependency: transitive description: name: ffi sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 url: "https://pub.dev" source: hosted version: "2.0.2" file: dependency: transitive description: name: file sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted version: "7.0.0" fixnum: dependency: transitive description: name: fixnum sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" url: "https://pub.dev" source: hosted version: "1.1.0" fl_chart: dependency: "direct main" description: name: fl_chart sha256: c1e26c7e48496be85104c16c040950b0436674cdf0737f3f6e95511b2529b592 url: "https://pub.dev" source: hosted version: "0.63.0" flex_color_scheme: dependency: "direct main" description: name: flex_color_scheme sha256: "659cf59bd5ccaa1e7de9384342be8b666ff10b108ed57a7fd46c122fb8bf6aca" url: "https://pub.dev" source: hosted version: "7.2.0" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" url: "https://pub.dev" source: hosted version: "1.4.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_hooks: dependency: "direct main" description: name: flutter_hooks sha256: b10cab7e0e4dbb60ff5360a740def3919aecbc672240f742a7130a2874204229 url: "https://pub.dev" source: hosted version: "0.19.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" url: "https://pub.dev" source: hosted version: "2.0.2" flutter_localizations: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_riverpod: dependency: "direct main" description: name: flutter_riverpod sha256: b83ac5827baadefd331ea1d85110f34645827ea234ccabf53a655f41901a9bf4 url: "https://pub.dev" source: hosted version: "2.3.6" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" fpdart: dependency: "direct main" description: name: fpdart sha256: "4a0d047c3359a4bdd19e4941603bbe394bd133b3772a38049e17f9534d47106e" url: "https://pub.dev" source: hosted version: "0.6.0" freezed: dependency: "direct main" description: name: freezed sha256: "2df89855fe181baae3b6d714dc3c4317acf4fccd495a6f36e5e00f24144c6c3b" url: "https://pub.dev" source: hosted version: "2.4.1" freezed_annotation: dependency: "direct main" description: name: freezed_annotation sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d url: "https://pub.dev" source: hosted version: "2.4.1" frontend_server_client: dependency: transitive description: name: frontend_server_client sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" url: "https://pub.dev" source: hosted version: "3.2.0" glob: dependency: transitive description: name: glob sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted version: "2.1.2" google_fonts: dependency: "direct main" description: name: google_fonts sha256: e20ff62b158b96f392bfc8afe29dee1503c94fbea2cbe8186fd59b756b8ae982 url: "https://pub.dev" source: hosted version: "5.1.0" graphs: dependency: transitive description: name: graphs sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 url: "https://pub.dev" source: hosted version: "2.3.1" hooks_riverpod: dependency: "direct main" description: name: hooks_riverpod sha256: "117edbe7e5cfc02e31a94f97e2acd4581f54bc37fcda9dce1f606f8ac851ba24" url: "https://pub.dev" source: hosted version: "2.3.7" hotreloader: dependency: transitive description: name: hotreloader sha256: "728c0613556c1d153f7e7f4a367cffacc3f5a677d7f6497a1c2b35add4e6dacf" url: "https://pub.dev" source: hosted version: "3.0.6" http: dependency: transitive description: name: http sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" url: "https://pub.dev" source: hosted version: "1.1.0" http_multi_server: dependency: transitive description: name: http_multi_server sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: dependency: transitive description: name: http_parser sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dev" source: hosted version: "4.0.2" intl: dependency: "direct main" description: name: intl sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 url: "https://pub.dev" source: hosted version: "0.18.0" intl_utils: dependency: "direct main" description: name: intl_utils sha256: a509a2ada4d12c4dc70f9ca35c2fddf75f8b402409ac1a9e1b3dd8065681986b url: "https://pub.dev" source: hosted version: "2.8.3" io: dependency: transitive description: name: io sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" url: "https://pub.dev" source: hosted version: "1.0.4" js: dependency: transitive description: name: js sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted version: "0.6.7" json_annotation: dependency: transitive description: name: json_annotation sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 url: "https://pub.dev" source: hosted version: "4.8.1" lints: dependency: transitive description: name: lints sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted version: "2.1.1" logging: dependency: transitive description: name: logging sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted version: "1.2.0" loggy: dependency: "direct main" description: name: loggy sha256: "981e03162bbd3a5a843026f75f73d26e4a0d8aa035ae060456ca7b30dfd1e339" url: "https://pub.dev" source: hosted version: "2.0.3" matcher: dependency: transitive description: name: matcher sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 url: "https://pub.dev" source: hosted version: "0.2.0" meta: dependency: transitive description: name: meta sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted version: "1.9.1" mime: dependency: transitive description: name: mime sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e url: "https://pub.dev" source: hosted version: "1.0.4" numeral: dependency: "direct main" description: name: numeral sha256: "3dc53e43920fe049d231665b24af760b5e2fca5f432c431f3c68cb7c0aee03f8" url: "https://pub.dev" source: hosted version: "2.0.1" package_config: dependency: transitive description: name: package_config sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: transitive description: name: path sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted version: "1.8.3" path_provider: dependency: transitive description: name: path_provider sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" url: "https://pub.dev" source: hosted version: "2.0.15" path_provider_android: dependency: transitive description: name: path_provider_android sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" url: "https://pub.dev" source: hosted version: "2.0.27" path_provider_foundation: dependency: transitive description: name: path_provider_foundation sha256: "916731ccbdce44d545414dd9961f26ba5fbaa74bcbb55237d8e65a623a8c7297" url: "https://pub.dev" source: hosted version: "2.2.4" path_provider_linux: dependency: transitive description: name: path_provider_linux sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 url: "https://pub.dev" source: hosted version: "2.1.11" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec" url: "https://pub.dev" source: hosted version: "2.0.6" path_provider_windows: dependency: transitive description: name: path_provider_windows sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" url: "https://pub.dev" source: hosted version: "2.1.7" petitparser: dependency: transitive description: name: petitparser sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 url: "https://pub.dev" source: hosted version: "5.4.0" platform: dependency: transitive description: name: platform sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" url: "https://pub.dev" source: hosted version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" url: "https://pub.dev" source: hosted version: "2.1.5" pointycastle: dependency: transitive description: name: pointycastle sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" url: "https://pub.dev" source: hosted version: "3.7.3" pool: dependency: transitive description: name: pool sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" url: "https://pub.dev" source: hosted version: "1.5.1" pub_semver: dependency: transitive description: name: pub_semver sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted version: "2.1.4" pubspec_parse: dependency: transitive description: name: pubspec_parse sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 url: "https://pub.dev" source: hosted version: "1.2.3" riverpod: dependency: transitive description: name: riverpod sha256: "80e48bebc83010d5e67a11c9514af6b44bbac1ec77b4333c8ea65dbc79e2d8ef" url: "https://pub.dev" source: hosted version: "2.3.6" riverpod_analyzer_utils: dependency: transitive description: name: riverpod_analyzer_utils sha256: "1b2632a6fc0b659c923a4dcc7cd5da42476f5b3294c70c86c971e63bdd443384" url: "https://pub.dev" source: hosted version: "0.3.1" riverpod_annotation: dependency: "direct main" description: name: riverpod_annotation sha256: cedd6a54b6f5764ffd5c05df57b6676bfc8c01978e14ee60a2c16891038820fe url: "https://pub.dev" source: hosted version: "2.1.1" riverpod_generator: dependency: "direct dev" description: name: riverpod_generator sha256: "691180275664a5420c87d72c1ed26ef8404d32b823807540172bfd1660425376" url: "https://pub.dev" source: hosted version: "2.2.4" riverpod_lint: dependency: "direct dev" description: name: riverpod_lint sha256: "17ad319914ac6863c64524e598913c0f17e30688aca8f5b7509e96d6e372d493" url: "https://pub.dev" source: hosted version: "1.4.0" rxdart: dependency: transitive description: name: rxdart sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" url: "https://pub.dev" source: hosted version: "0.27.7" shelf: dependency: transitive description: name: shelf sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted version: "1.4.1" shelf_web_socket: dependency: transitive description: name: shelf_web_socket sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted version: "1.0.4" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" source_gen: dependency: transitive description: name: source_gen sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16 url: "https://pub.dev" source: hosted version: "1.4.0" source_span: dependency: transitive description: name: source_span sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 url: "https://pub.dev" source: hosted version: "1.9.1" squadron: dependency: "direct main" description: name: squadron sha256: b2dd9457091063e7744a71f6d842daae7cb67eadcd8a3c2c5a2b18f6b9d2d664 url: "https://pub.dev" source: hosted version: "5.1.3" squadron_builder: dependency: "direct main" description: name: squadron_builder sha256: "5df2be97d8f18a9a7f25b22d8ff1b81449ebcbc916343abb3f8a949b3a379396" url: "https://pub.dev" source: hosted version: "2.4.1" stack_trace: dependency: transitive description: name: stack_trace sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 url: "https://pub.dev" source: hosted version: "1.11.0" state_notifier: dependency: transitive description: name: state_notifier sha256: "8fe42610f179b843b12371e40db58c9444f8757f8b69d181c97e50787caed289" url: "https://pub.dev" source: hosted version: "0.7.2+1" stream_channel: dependency: transitive description: name: stream_channel sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" url: "https://pub.dev" source: hosted version: "2.1.1" stream_transform: dependency: transitive description: name: stream_transform sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" url: "https://pub.dev" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted version: "0.5.1" timing: dependency: transitive description: name: timing sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" url: "https://pub.dev" source: hosted version: "1.0.1" typed_data: dependency: transitive description: name: typed_data sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted version: "1.3.2" uuid: dependency: "direct main" description: name: uuid sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" url: "https://pub.dev" source: hosted version: "3.0.7" vector_math: dependency: transitive description: name: vector_math sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" url: "https://pub.dev" source: hosted version: "2.1.4" vm_service: dependency: transitive description: name: vm_service sha256: ada49637c27973c183dad90beb6bd781eea4c9f5f955d35da172de0af7bd3440 url: "https://pub.dev" source: hosted version: "11.8.0" watcher: dependency: transitive description: name: watcher sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted version: "1.1.0" web_socket_channel: dependency: transitive description: name: web_socket_channel sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b url: "https://pub.dev" source: hosted version: "2.4.0" win32: dependency: transitive description: name: win32 sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0 url: "https://pub.dev" source: hosted version: "5.0.6" xdg_directories: dependency: transitive description: name: xdg_directories sha256: e0b1147eec179d3911f1f19b59206448f78195ca1d20514134e10641b7d7fbff url: "https://pub.dev" source: hosted version: "1.0.1" yaml: dependency: transitive description: name: yaml sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted version: "3.1.2" sdks: dart: ">=3.0.6 <4.0.0" flutter: ">=3.10.0" ```
Code ```dart import 'dart:async'; import 'package:squadron/squadron.dart'; import 'package:squadron/squadron_annotations.dart'; import 'live_feed.activator.g.dart'; part 'live_feed.worker.g.dart'; @SquadronService() class LiveFeedService implements WorkerService { @SquadronMethod() Stream pulse() async* { var n = 0; while (true) { yield n.toDouble(); n += 1; await Future.delayed(const Duration(milliseconds: 100)); } } @override Map get operations => throw UnimplementedError(); } ``` Generated ```dart // GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** // Generator: WorkerGenerator 2.4.1 // ************************************************************************** import 'live_feed.stub.g.dart' if (dart.library.js) 'live_feed.web.g.dart' if (dart.library.html) 'live_feed.web.g.dart' if (dart.library.io) 'live_feed.vm.g.dart'; /// Service activator for LiveFeedService final $LiveFeedServiceActivator = $getLiveFeedServiceActivator(); ``` ```dart // GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** // Generator: WorkerGenerator 2.4.1 // ************************************************************************** import 'package:squadron/squadron.dart'; EntryPoint $getLiveFeedServiceActivator() => throw UnimplementedError(); ``` ```dart // GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** // Generator: WorkerGenerator 2.4.1 // ************************************************************************** import 'package:squadron/squadron.dart'; import 'live_feed.dart'; /// VM entry point for LiveFeedService void _start$LiveFeedService(List command) => run($LiveFeedServiceInitializer, command, null); EntryPoint $getLiveFeedServiceActivator() => _start$LiveFeedService; ``` ```dart // GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** // Generator: WorkerGenerator 2.4.1 // ************************************************************************** import 'package:squadron/squadron.dart'; import 'live_feed.dart'; void main() { /// Web entry point for LiveFeedService run($LiveFeedServiceInitializer, null, null); } EntryPoint $getLiveFeedServiceActivator() => 'lib/service/live_feed/live_feed.web.g.dart.js'; ``` ```dart // GENERATED CODE - DO NOT MODIFY BY HAND part of 'live_feed.dart'; // ************************************************************************** // Generator: WorkerGenerator 2.4.1 // ************************************************************************** /// WorkerService class for LiveFeedService class _$LiveFeedServiceWorkerService extends LiveFeedService implements WorkerService { _$LiveFeedServiceWorkerService() : super(); @override Map get operations => _operations; late final Map _operations = {_$pulseId: ($) => pulse()}; static const int _$pulseId = 1; } /// Service initializer for LiveFeedService WorkerService $LiveFeedServiceInitializer(WorkerRequest startRequest) => _$LiveFeedServiceWorkerService(); /// Operations map for LiveFeedService @Deprecated( 'squadron_builder now supports "plain old Dart objects" as services. ' 'Services do not need to derive from WorkerService nor do they need to mix in ' 'with \$LiveFeedServiceOperations anymore.') mixin $LiveFeedServiceOperations on WorkerService { @override // not needed anymore, generated for compatibility with previous versions of squadron_builder Map get operations => WorkerService.noOperations; } /// Worker for LiveFeedService class LiveFeedServiceWorker extends Worker implements LiveFeedService { LiveFeedServiceWorker({PlatformWorkerHook? platformWorkerHook}) : super($LiveFeedServiceActivator, platformWorkerHook: platformWorkerHook); @override Stream pulse() => stream(_$LiveFeedServiceWorkerService._$pulseId, args: []); @override Map Function(List)> get operations => throw UnimplementedError(); } /// Worker pool for LiveFeedService class LiveFeedServiceWorkerPool extends WorkerPool implements LiveFeedService { LiveFeedServiceWorkerPool( {ConcurrencySettings? concurrencySettings, PlatformWorkerHook? platformWorkerHook}) : super( () => LiveFeedServiceWorker(platformWorkerHook: platformWorkerHook), concurrencySettings: concurrencySettings); @override Stream pulse() => stream((w) => w.pulse()); @override Map Function(List)> get operations => throw UnimplementedError(); } ``` Worker trigger at startup. ```dart void main() async { Loggy.initLoggy( logOptions: LogOptions( LogLevel.values .firstWhere((level) => level.priority == ConfigValues.logLevel), ), ); final worker = LiveFeedServiceWorker(); await worker.start(); runApp( ProviderScope( overrides: [], observers: [if (ConfigValues.observeProviders) ProviderDebugObserver()], child: const WrkAteEdgeApp( appVersion: ConfigValues.appVersion, showDebugBanner: ConfigValues.showDebugBanner, ), ), ); } ``` ## I have tried 1. clean and rebuild. 2. using a build.yaml to direct where the generated files land. 3. calling start lower in the tree, like within a Widget. 4. specifying a base url in the annotation. So I am at a bit of a lost, it 'Appears' to work for Android but certainly not on the web.
d-markey commented 11 months ago

Hello,

the message indicates the script was found otherwise you'd have had a 404, but the MIME type provided by the web server was unexpected (text/html) so Chrome won't execute it for security reason. I've had this issue on Windows and fixing the registry worked for me:

Alternatively, you might try to run a release build in a production-like environment (not using Dart/Flutter's Web server).

On a side note, it seems you're using the latest version of squadron_builder so you can simplify your service class:

@SquadronService()
class LiveFeedService {
  @SquadronMethod()
  Stream<double> pulse() async* {
    var n = 0;
    while (true) {
      yield n.toDouble();
      n += 1;
      await Future.delayed(const Duration(milliseconds: 100));
    }
  }
}

Please note that this service is not interruptible because it lacks a CancellationToken parameter, so once it is listened to, I guess it will run forever you will have to properly cancel the subscription to stop the streaming operation.

d-markey commented 10 months ago

Hello, following up on this issue. Did you manage to have it work on the Web?

d-markey commented 10 months ago

Not a Squadron issue / No follow up in the last month --> Closing

sabin26 commented 9 months ago

I am facing the same issue. If it only works in production environment (not tested yet) then it is a productivity killer while developing in debug mode.

d-markey commented 9 months ago

Hello, unfortunately, I don't know why Flutter's dev Web server responds with a 'text/html' MIME type in your case, but that prevents your browser from running the Worker code. Have you checked your browser's dev tools to see what's going on? Maybe the URI to your worker script is incorrect? When using squadron_builder, you can specify the base URL to your worker via the SuqadronService annotation.

I remember I ran into a similar problem when I started this project, but I managed to fix it although I can't remember exactly how. I've added a proper key for ".js" mime type in the Windows registry, and I remember also fiddling with Chrome's security settings. Eventually the problem disappeared.

sabin26 commented 9 months ago

I have checked my browser's dev tools and here is the stack:

js_primitives.dart:30 ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
js_primitives.dart:30 The following CancelledException was thrown:
js_primitives.dart:30 [-3,"provisionning workers failed","dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart
js_primitives.dart:30 941:28   get current\npackages/squadron/src/worker_exception.dart 17:34
js_primitives.dart:30 new\npackages/squadron/src/worker_exception.dart 71:9
js_primitives.dart:30 new\npackages/squadron/src/xplat/_worker_task.dart 50:29
js_primitives.dart:30 cancel\npackages/squadron/src/xplat/_worker_value_task.dart 33:11
js_primitives.dart:30 cancel\npackages/squadron/src/worker_pool.dart 303:32
js_primitives.dart:30 <fn>\ndart-sdk/lib/async/zone.dart 1407:47
js_primitives.dart:30 _rootRunUnary\ndart-sdk/lib/async/zone.dart 1308:19
js_primitives.dart:30 runUnary\ndart-sdk/lib/async/future_impl.dart 174:22
js_primitives.dart:30 handleError\ndart-sdk/lib/async/future_impl.dart 852:46
js_primitives.dart:30 handleError\ndart-sdk/lib/async/future_impl.dart 873:13
js_primitives.dart:30 _propagateToListeners\ndart-sdk/lib/async/future_impl.dart 641:5
js_primitives.dart:30 [_completeWithValue]\ndart-sdk/lib/async/future.dart 531:22
js_primitives.dart:30 <fn>\ndart-sdk/lib/async/zone.dart 1407:47
js_primitives.dart:30 _rootRunUnary\ndart-sdk/lib/async/zone.dart 1308:19
js_primitives.dart:30 runUnary\ndart-sdk/lib/async/future_impl.dart 156:18
js_primitives.dart:30 handleValue\ndart-sdk/lib/async/future_impl.dart 840:44
js_primitives.dart:30 handleValueCallback\ndart-sdk/lib/async/future_impl.dart 869:13
js_primitives.dart:30 _propagateToListeners\ndart-sdk/lib/async/future_impl.dart 649:5
js_primitives.dart:30 [_completeError]\ndart-sdk/lib/async/future_impl.dart 739:7
js_primitives.dart:30 <fn>\ndart-sdk/lib/async/zone.dart 1399:13
js_primitives.dart:30 _rootRun\ndart-sdk/lib/async/zone.dart 1301:19
js_primitives.dart:30 run\ndart-sdk/lib/async/zone.dart 1209:7
js_primitives.dart:30 runGuarded\ndart-sdk/lib/async/zone.dart 1249:23
js_primitives.dart:30 callback\ndart-sdk/lib/async/schedule_microtask.dart 40:11
js_primitives.dart:30 _microtaskLoop\ndart-sdk/lib/async/schedule_microtask.dart 49:5
js_primitives.dart:30 _startMicrotaskLoop\ndart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15
js_primitives.dart:30 <fn>\n",null,null]
js_primitives.dart:30 
js_primitives.dart:30 When the exception was thrown, this was the stack:
js_primitives.dart:30 dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 941:28   get current
js_primitives.dart:30 packages/squadron/src/worker_exception.dart 17:34                    new
js_primitives.dart:30 packages/squadron/src/worker_exception.dart 71:9                     new
js_primitives.dart:30 packages/squadron/src/xplat/_worker_task.dart 50:29                  cancel
js_primitives.dart:30 packages/squadron/src/xplat/_worker_value_task.dart 33:11            cancel
js_primitives.dart:30 packages/squadron/src/worker_pool.dart 303:32                        <fn>
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1407:47                                 _rootRunUnary
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1308:19                                 runUnary
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 174:22                           handleError
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 852:46                           handleError
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 873:13                           _propagateToListeners
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 641:5                            [_completeWithValue]
js_primitives.dart:30 dart-sdk/lib/async/future.dart 531:22                                <fn>
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1407:47                                 _rootRunUnary
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1308:19                                 runUnary
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 156:18                           handleValue
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 840:44                           handleValueCallback
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 869:13                           _propagateToListeners
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 649:5                            [_completeError]
js_primitives.dart:30 dart-sdk/lib/async/future_impl.dart 739:7                            <fn>
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1399:13                                 _rootRun
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1301:19                                 run
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1209:7                                  runGuarded
js_primitives.dart:30 dart-sdk/lib/async/zone.dart 1249:23                                 callback
js_primitives.dart:30 dart-sdk/lib/async/schedule_microtask.dart 40:11                     _microtaskLoop
js_primitives.dart:30 dart-sdk/lib/async/schedule_microtask.dart 49:5                      _startMicrotaskLoop
js_primitives.dart:30 dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15  <fn>
js_primitives.dart:30 ════════════════════════════════════════════════════════════════════════════════════════════════════
localhost/:1 Refused to execute script from 'http://localhost:59330/lib/dependencies/api/http_service.web.g.dart.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:59330/lib/dependencies/websocket_client/websocket_service.web.g.dart.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Here is another stack from the UI (Screenshot):

squadron-bug

I am using squadron_builder and I expect it to provide correct Uri to my worker scripts or am I supposed to provide one?

I also tried these steps you mentioned but the key was already present on my windows machine.

  • open key "HKEY_CLASSES_ROOT.js" in the Windows Registry,
  • I assume the "Content Type" key is missing
  • create the "Content Type" key with value "application/javascript"
d-markey commented 9 months ago

On Web platform, the Dart code must be compiled to JavaScript and copied to the web output (typically somewhere in the /web folder). This step is not handled by squadron_builder and the baseUrl provided to SquadronService must match the subfolder where the JS lives. squadron_builder will only take care of the file name (appending ".js" to the original Dart file name).

Eg.

dart compile js .\lib\src\my_service.web.g.dart -o .\web\abc\my_service.web.g.dart.js -m

You can refer to https://github.com/d-markey/squadron_sample for an example.

Now to check if your browser found the JS worker, can you check the network tab in Chrome's devtools and look for the entry to the JS worker URI? If the response is a 404 you need to provide the proper baseUrl matching the output of your dart compile js command for your worker.

d-markey commented 9 months ago

PS @sabin26 referring to your other issue (passing a Function to a Worker method -- https://github.com/d-markey/squadron/issues/26) please note that this won't work on Web. Functions cannot be transferred to a Web Worker.

sabin26 commented 9 months ago

PS @sabin26 referring to your other issue (passing a Function to a Worker method -- https://github.com/d-markey/squadron/issues/26) please note that this won't work on Web. Functions cannot be transferred to a Web Worker.

I have worked around that issue by not passing a function as an argument to the worker task. I return the Map from the worker and use Model.fromJson in the main thread now.

sabin26 commented 9 months ago

On Web platform, the Dart code must be compiled to JavaScript and copied to the web output (typically somewhere in the /web folder). This step is not handled by squadron_builder and the baseUrl provided to SquadronService must match the subfolder where the JS lives. squadron_builder will only take care of the file name (appending ".js" to the original Dart file name).

Eg.

  • your service is implemented in "my_service.dart"
  • you provide "/abc" as the baseUrl
  • squadron_builder generates several files, including "my_service.web.g.dart"
  • this file contains the target URL to your JS worker: "/abc/my_service.web.g.dart.js"
  • then before running you app in your browser, you need to compile the JS code like this:

dart compile js .\lib\src\my_service.web.g.dart -o .\web\abc\my_service.web.g.dart.js -m

You can refer to https://github.com/d-markey/squadron_sample for an example.

Now to check if your browser found the JS worker, can you check the network tab in Chrome's devtools and look for the entry to the JS worker URI? If the response is a 404 you need to provide the proper baseUrl matching the output of your dart compile js command for your worker.

Although I am still stuck on making my worker work on the web, I am no longer getting MIME error by following the above steps correctly. I can see the worker.js on the Network Tab with status code: 200. You can close the issue now. Thank you for your help.

d-markey commented 9 months ago

Dont hesitate to open another issue If you need help