Skip to content

Commit 6c0e88f

Browse files
committed
Remove isolate buffering.
It seems like dart-lang/sdk#12617 got fixed at some point.
1 parent 97a4054 commit 6c0e88f

File tree

2 files changed

+3
-38
lines changed

2 files changed

+3
-38
lines changed

lib/src/barback/transformer_isolate.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ class TransformerIsolate {
8080
snapshot: snapshot);
8181
return new TransformerIsolate._(
8282
await port.first, environment.mode, idsToUrls);
83-
} on CrossIsolateException catch (error, stackTrace) {
84-
if (error.type != 'IsolateSpawnException') throw error;
85-
83+
} on IsolateSpawnException catch (error, stackTrace) {
8684
// TODO(nweiz): don't parse this as a string once issues 12617 and 12689
8785
// are fixed.
8886
var firstErrorLine = error.message.split('\n')[1];

lib/src/dart.dart

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import 'package:compiler_unsupported/src/filenames.dart'
1414
show appendSlash;
1515
import 'package:path/path.dart' as p;
1616

17-
import 'asset/dart/serialize.dart';
1817
import 'exceptions.dart';
1918
import 'io.dart';
2019
import 'log.dart' as log;
@@ -177,19 +176,8 @@ Future runInIsolate(String code, message, {packageRoot, String snapshot})
177176
await withTempDir((dir) async {
178177
var dartPath = p.join(dir, 'runInIsolate.dart');
179178
writeTextFile(dartPath, code, dontLogContents: true);
180-
var port = new ReceivePort();
181-
await Isolate.spawn(_isolateBuffer, {
182-
'replyTo': port.sendPort,
183-
// Make the snapshot URI absolute to work around sdk#8440.
184-
'uri': p.toUri(p.absolute(dartPath)).toString(),
185-
'packageRoot': packageRoot == null ? null : packageRoot.toString(),
186-
'message': message
187-
});
188-
189-
var response = await port.first;
190-
if (response['type'] == 'error') {
191-
throw new CrossIsolateException.deserialize(response['error']);
192-
}
179+
await Isolate.spawnUri(p.toUri(p.absolute(dartPath)), [], message,
180+
packageRoot: packageRoot);
193181

194182
if (snapshot == null) return;
195183

@@ -208,27 +196,6 @@ Future runInIsolate(String code, message, {packageRoot, String snapshot})
208196
});
209197
}
210198

211-
// TODO(nweiz): remove this when issue 12617 is fixed.
212-
/// A function used as a buffer between the host isolate and [spawnUri].
213-
///
214-
/// [spawnUri] synchronously loads the file and its imports, which can deadlock
215-
/// the host isolate if there's an HTTP import pointing at a server in the host.
216-
/// Adding an additional isolate in the middle works around this.
217-
void _isolateBuffer(message) {
218-
var replyTo = message['replyTo'];
219-
var packageRoot = message['packageRoot'];
220-
if (packageRoot != null) packageRoot = Uri.parse(packageRoot);
221-
Isolate.spawnUri(Uri.parse(message['uri']), [], message['message'],
222-
packageRoot: packageRoot)
223-
.then((_) => replyTo.send({'type': 'success'}))
224-
.catchError((e, stack) {
225-
replyTo.send({
226-
'type': 'error',
227-
'error': CrossIsolateException.serialize(e, stack)
228-
});
229-
});
230-
}
231-
232199
/// Snapshots the Dart executable at [executableUrl] to a snapshot at
233200
/// [snapshotPath].
234201
///

0 commit comments

Comments
 (0)