Chromium Code Reviews

Unified Diff: sdk/lib/_internal/pub/lib/src/dart.dart

Issue 593363002: Regenerate a snapshot if the first isolate fails to load. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | sdk/lib/_internal/pub_generated/lib/src/dart.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/dart.dart
diff --git a/sdk/lib/_internal/pub/lib/src/dart.dart b/sdk/lib/_internal/pub/lib/src/dart.dart
index 650d3aad3be8dafd751d9c4a6b3012720a95c524..0b5ab8cd7b92e35c1668f3a973fda2425de3bc22 100644
--- a/sdk/lib/_internal/pub/lib/src/dart.dart
+++ b/sdk/lib/_internal/pub/lib/src/dart.dart
@@ -153,15 +153,22 @@ class _DirectiveCollector extends GeneralizingAstVisitor {
/// If [snapshot] is passed, the isolate will be loaded from that path if it
/// exists. Otherwise, a snapshot of the isolate's code will be saved to that
/// path once the isolate is loaded.
-Future runInIsolate(String code, message, {packageRoot, String snapshot}) {
+Future runInIsolate(String code, message, {packageRoot, String snapshot})
+ async {
if (snapshot != null && fileExists(snapshot)) {
log.fine("Spawning isolate from $snapshot.");
if (packageRoot != null) packageRoot = packageRoot.toString();
- return Isolate.spawnUri(path.toUri(snapshot), [], message,
- packageRoot: packageRoot);
+ try {
+ await Isolate.spawnUri(path.toUri(snapshot), [], message,
+ packageRoot: packageRoot);
+ return;
+ } on IsolateSpawnException catch (error) {
+ log.fine("Couldn't load existing snapshot $snapshot:\n$error");
+ // Do nothing, we will regenerate the snapshot below.
+ }
}
- return withTempDir((dir) async {
+ await withTempDir((dir) async {
var dartPath = path.join(dir, 'runInIsolate.dart');
writeTextFile(dartPath, code, dontLogContents: true);
var port = new ReceivePort();
« no previous file with comments | « no previous file | sdk/lib/_internal/pub_generated/lib/src/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine