dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.31k stars 1.59k forks source link

Runtime error when building using fetch() #34924

Open mnordine opened 6 years ago

mnordine commented 6 years ago
final fetch = WorkerGlobalScope.instance.fetch;

final response = await fetch('https://api.github.com/users/mnordine');
final json = await response.text();
print(json);

This throws a runtime error when doing webdev build, but it doesn't with webdev build --no-release

kevmoo commented 6 years ago

@mnordine – does it "work" with --no-release? Sounds like a difference between how the dev compiler handles things and dart2js...

mnordine commented 6 years ago

does it "work" with --no-release

Yep, it prints out expected output

robbecker-wf commented 5 years ago

+1, I'd like to see this work with both DDC and dart2js

georgelesica-wf commented 5 years ago

We're running into this problem. I put together a minimal test case here https://github.com/georgelesica-wf/web_worker_example/tree/broken. Another issue, perhaps unrelated, is that DedicatedWorkerGlobalScope.instance produces an analyzer warning. Not the end of the world, but annoying.

image