This reverts commit 283ec9e2a1.
This commit is contained in:
@@ -40,20 +40,12 @@ Future<Map<String, dynamic>> runTask(
|
||||
|
||||
bool runnerFinished = false;
|
||||
|
||||
final Completer<Uri> uri = Completer<Uri>();
|
||||
|
||||
runner.exitCode.whenComplete(() {
|
||||
if (!uri.isCompleted) {
|
||||
// The runner process exited prematurely.
|
||||
uri.completeError(Exception(
|
||||
'The task runner process exited before opening a VM service connection. '
|
||||
'A common cause for this is when a task script does not actually create '
|
||||
'a task.',
|
||||
));
|
||||
}
|
||||
runnerFinished = true;
|
||||
});
|
||||
|
||||
final Completer<Uri> uri = Completer<Uri>();
|
||||
|
||||
final StreamSubscription<String> stdoutSub = runner.stdout
|
||||
.transform<String>(const Utf8Decoder())
|
||||
.transform<String>(const LineSplitter())
|
||||
@@ -76,7 +68,7 @@ Future<Map<String, dynamic>> runTask(
|
||||
});
|
||||
|
||||
try {
|
||||
final VMIsolateRef isolate = await _connectToRunnerIsolate(await uri.future, () => !runnerFinished);
|
||||
final VMIsolateRef isolate = await _connectToRunnerIsolate(await uri.future);
|
||||
final Map<String, dynamic> taskResult = await isolate.invokeExtension('ext.cocoonRunTask') as Map<String, dynamic>;
|
||||
await runner.exitCode;
|
||||
return taskResult;
|
||||
@@ -89,7 +81,7 @@ Future<Map<String, dynamic>> runTask(
|
||||
}
|
||||
}
|
||||
|
||||
Future<VMIsolateRef> _connectToRunnerIsolate(Uri vmServiceUri, bool Function() keepTrying) async {
|
||||
Future<VMIsolateRef> _connectToRunnerIsolate(Uri vmServiceUri) async {
|
||||
final List<String> pathSegments = <String>[
|
||||
// Add authentication code.
|
||||
if (vmServiceUri.pathSegments.isNotEmpty) vmServiceUri.pathSegments[0],
|
||||
@@ -99,7 +91,7 @@ Future<VMIsolateRef> _connectToRunnerIsolate(Uri vmServiceUri, bool Function() k
|
||||
pathSegments).toString();
|
||||
final Stopwatch stopwatch = Stopwatch()..start();
|
||||
|
||||
while (keepTrying()) {
|
||||
while (true) {
|
||||
try {
|
||||
// Make sure VM server is up by successfully opening and closing a socket.
|
||||
await (await WebSocket.connect(url)).close();
|
||||
@@ -118,8 +110,6 @@ Future<VMIsolateRef> _connectToRunnerIsolate(Uri vmServiceUri, bool Function() k
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
}
|
||||
}
|
||||
|
||||
throw Exception('Failed to connect to Dart VM service.');
|
||||
}
|
||||
|
||||
Future<void> cleanupSystem() async {
|
||||
|
||||
Reference in New Issue
Block a user