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

HttpRequest from dart:html don't not work in web workers on Safari #51918

Open
simolus3 opened this issue Apr 1, 2023 · 1 comment
Open

HttpRequest from dart:html don't not work in web workers on Safari #51918

simolus3 opened this issue Apr 1, 2023 · 1 comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dart2js

Comments

@simolus3
Copy link
Contributor

simolus3 commented Apr 1, 2023

XMLHttpRequests which, according to MDN should work in regular web workers, don't work in Safari web workers when used through dart:html.

To reproduce this issue, setup a new Dart web project from the template (dart create -t xhr_worker). Create a new file web/worker.dart with the following content:

import 'dart:html';

void main() async {
  print(await HttpRequest.getString('index.html'));
}

Also, change web/main.dart as follows:

import 'dart:html';

void main() async {
  Worker('worker.dart.js');
}

I run this example with dart run build_runner serve "--define=build_web_compilers:entrypoint=compiler=dart2js" web:8080.

This works in Firefox and in Chrome, but fails in Safari (throws in _failedAsCheck, where object is an XMLHttpRequestProgressEvent and testRti is the RTI for Event).
Also, it's interesting that J.getInterceptor$(new Event('a')) returns a Dart Event, but J.getInterceptor$(object) returns an UnknownJavaScriptObject, even though the object is an event as well. I suspect this is because, despite these events being delivered in workers, the global scope for workers does not include XMLHttpRequestProgressEvent in Safari. Is there a way for the Dart SDK to work around this issue?

@lrhn lrhn added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Apr 1, 2023
@tangenttechno
Copy link

same issue for me too. Runs fine in chrome. but fails in safari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants