Open
Description
SharedWorkerGlobalScope
throws Uncaught Error: Expected a value of type 'SharedWorkerGlobalScope', but got one of type 'Window'
exception. I discovered this issue in a Flutter project, but I can reproduce on bare Dart.
It worked some months ago.
errors.dart:248 Uncaught Error: Expected a value of type 'SharedWorkerGlobalScope', but got one of type 'Window'
at Object.throw_ [as throw] (errors.dart:248:21)
at Object.castError (errors.dart:84:3)
at Object.cast [as as] (operations.dart:452:10)
at Function.as_C [as as] (classes.dart:635:14)
at Function.get instance [as instance] (html_dart2js.dart:28187:24)
at main$ (main.dart:4:42)
at main.dart.bootstrap.js:267:10
at Array.forEach (<anonymous>)
at window.$dartRunMain (main.dart.bootstrap.js:266:32)
at <anonymous>:1:8
at Object.runMain (client.js:8805:21)
at client.js:24459:19
at _wrapJsFunctionForAsync_closure.$protected (client.js:3475:15)
at _wrapJsFunctionForAsync_closure.call$2 (client.js:11564:12)
at Object._asyncStartSync (client.js:3439:20)
at main__closure4.$call$body$main__closure (client.js:24472:16)
at main__closure4.call$1 (client.js:24398:19)
at StaticClosure._rootRunUnary (client.js:3843:16)
at _CustomZone.runUnary$2$2 (client.js:12970:39)
at _CustomZone.runUnaryGuarded$1$2 (client.js:12917:14)
at _ControllerSubscription._sendData$1 (client.js:12504:19)
at _DelayedData.perform$1 (client.js:12686:59)
at _PendingEvents_schedule_closure.call$0 (client.js:12735:14)
at Object._microtaskLoop (client.js:3681:24)
at StaticClosure._startMicrotaskLoop (client.js:3687:11)
at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (client.js:11440:9)
at invokeClosure (client.js:1274:26)
at MutationObserver.<anonymous> (client.js:1293:18)
Reproduce:
dart create -t web-simple worker_sample
- Add
final worker = SharedWorkerGlobalScope.instance;
tomain()
- Run
Dart SDK version: 2.16.2 (stable) (Tue Mar 22 13:15:13 2022 +0100) on "macos_x64"
MacOS 12.3.1 (21E258)
Chrome 100.0.4896.127 (Hivatalos verzió) (arm64)