public
Created

mongo dart bug in isolate. Illegal instruction: 4

  • Download Gist
test_isolate.dart
Dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
#import("dart:isolate");
#import('../../mongo-dart/lib/mongo.dart');
/*
1) Clone the mongo dart project and reference the correct import location
2) dart test_isolate.dart
 
13:37:00-adam@Adams-MacBook-Air:~/dart/test
$ dart test_isolate.dart
enter find
Illegal instruction: 4
 
*/
 
 
// class used for simple async class
class AnotherAsyncClass {
Future open() {
Completer c = new Completer();
c.complete("blamamal");
return c.future;
}
}
 
 
Future<String> find(msg) {
print("enter find");
Completer completer = new Completer();
// Creates the following error: Illegal instruction: 4
Db db = new Db('some-db-test');
 
completer.complete("some dummy data, comment out to test db.open() or a.open()");
// DbCollection collection;
// AnotherAsyncClass a = new AnotherAsyncClass();
// a.open().then((_) {
//
// });
// print("before db.open in find");
// db.open().chain((_){
// print("open db in find");
// collection = db.collection("somecollection");
// return collection.findOne({"somefield":msg});
// }).chain((v){
// completer.complete(v);
// });
print("ret find");
return completer.future;
}
 
new_isolate() {
port.receive((msg, reply) {
Future f = find(msg);
f.handleException((e)=>print("e = ${e}"));
f.then((r)=>reply.send(r));
});
}
 
main() {
spawnFunction(new_isolate).call("findme").then((s)=>print("s=$s"));
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.