The following code crashes Dartium ("Aw, Snap") because of "new HttpRequest()" in iso().
#import('dart:isolate');
#import('dart:html');
void main() {
spawnFunction(iso).send('ping', port.toSendPort());
port.receive((msg, _) => print('pong: $msg'));
}
iso () {
port.receive((msg, reply) {
var req = new HttpRequest();
reply.send('responding');
});
}
How does one make an HTTP request from an isolate in the browser? I'd like to do this in the following use cases:
- running untrusted code in the browser (eg, custom web app hooks written in Dart)
- expensive processing of web data (eg, generate encryption keys from random.org data)
- run same isolate code in browser and server
- isolates for structural clarity (eg, one isolate per activity)
None of these isolates want access to the DOM, so DOM isolates (
issue 3050) seem like overkill. Maybe that's the best way available.
Suggestions?
--
Michael