Skip to content

HttpRequest not supported in non-DOM isolates in Dartium #10223

Closed
@peter-ahe-google

Description

@peter-ahe-google

This program works fine in dart2js:

import 'dart:isolate';
import 'dart:html' show HttpRequest;

useHttpRequest() {
  port.receive((String uri, SendPort replyTo) {
    try {
      HttpRequest.getString('test.dart').then((text) => replyTo.send(text));
    } catch (e, trace) {
      replyTo.send('$e\n$trace');
    }
  });
}

main() {
  print('Starting isolate');
  spawnFunction(useHttpRequest).call('test.dart').then((reply) => print('Reply: $reply'));
}

The console shows:

Starting isolate test.dart.js:4629
Reply: import 'dart:isolate';
import 'dart:html' show HttpRequest;

useHttpRequest() {
  port.receive((String uri, SendPort replyTo) {
    try {
      // replyTo.send('Hello');
      HttpRequest.getString('test.dart').then((text) => replyTo.send(text));
    } catch (e, trace) {
      replyTo.send('$e\n$trace');
    }
  });
}

main() {
  print('Starting isolate');
  spawnFunction(useHttpRequest).call('test.dart').then((reply) => print('Reply: $reply'));
}
 test.dart.js:4629

Unfortunately, sadness descents on Dartium. This is what is printed in the console:

Starting isolate undefined:1
Reply: DOM access is not enabled in this isolate

­0 HttpRequest._create (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:60:3)

­1 HttpRequest.HttpRequest (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:58:35)

­2 HttpRequest.request (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:10:15)

­3 HttpRequest.getString (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:5:19)

­4 useHttpRequest.<anonymous closure> (http://127.0.0.1:56653/web_editor/test.dart:6:28)

­5 _ReceivePortImpl._handleMessage (dart:isolate-patch:81:92)

 undefined:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work ontype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions