@@ -31,55 +31,21 @@ Future<IsolateWrapper> runInIsolate(String code, message, {packageRoot}) async {
31
31
var dir = createTempDir ();
32
32
var dartPath = p.join (dir, 'runInIsolate.dart' );
33
33
new File (dartPath).writeAsStringSync (code);
34
- var port = new ReceivePort ();
35
34
36
- try {
37
- var isolate = await Isolate .spawn (_isolateBuffer, {
38
- 'replyTo' : port.sendPort,
39
- 'uri' : p.toUri (dartPath).toString (),
40
- 'packageRoot' : packageRoot == null ? null : packageRoot.toString (),
41
- 'message' : message
42
- });
43
-
44
- var response = await port.first;
45
- if (response['type' ] != 'error' ) {
46
- return new IsolateWrapper (isolate,
47
- () => new Directory (dir).deleteSync (recursive: true ));
48
- }
35
+ if (packageRoot is String ) packageRoot = Uri .parse (packageRoot);
49
36
50
- isolate.kill ();
51
- var asyncError = RemoteException .deserialize (response['error' ]);
52
- await new Future .error (asyncError.error, asyncError.stackTrace);
53
- throw 'unreachable' ;
37
+ try {
38
+ var isolate = await Isolate .spawnUri (
39
+ p.toUri (dartPath), [], message,
40
+ packageRoot: packageRoot);
41
+ return new IsolateWrapper (isolate,
42
+ () => new Directory (dir).deleteSync (recursive: true ));
54
43
} catch (error) {
55
44
new Directory (dir).deleteSync (recursive: true );
56
45
rethrow ;
57
46
}
58
47
}
59
48
60
- // TODO(nweiz): remove this when issue 12617 is fixed.
61
- /// A function used as a buffer between the host isolate and [spawnUri] .
62
- ///
63
- /// [spawnUri] synchronously loads the file and its imports, which can deadlock
64
- /// the host isolate if there's an HTTP import pointing at a server in the host.
65
- /// Adding an additional isolate in the middle works around this.
66
- Future _isolateBuffer (message) async {
67
- var replyTo = message['replyTo' ];
68
- var packageRoot = message['packageRoot' ];
69
- if (packageRoot != null ) packageRoot = Uri .parse (packageRoot);
70
-
71
- try {
72
- await Isolate .spawnUri (Uri .parse (message['uri' ]), [], message['message' ],
73
- packageRoot: packageRoot);
74
- replyTo.send ({'type' : 'success' });
75
- } catch (error, stackTrace) {
76
- replyTo.send ({
77
- 'type' : 'error' ,
78
- 'error' : RemoteException .serialize (error, stackTrace)
79
- });
80
- }
81
- }
82
-
83
49
// TODO(nweiz): Move this into the analyzer once it starts using SourceSpan
84
50
// (issue 22977).
85
51
/// Takes a span whose source is the value of a string that has been parsed from
0 commit comments