Index: pkg/barback/lib/src/transform.dart |
diff --git a/pkg/barback/lib/src/transform.dart b/pkg/barback/lib/src/transform.dart |
index cb5175305c7a05339079dbecc1f4aba2db92c8d9..3eb3a29ba16a9b03a7309b2d0aa1f557eb0bb6d2 100644 |
--- a/pkg/barback/lib/src/transform.dart |
+++ b/pkg/barback/lib/src/transform.dart |
@@ -67,9 +67,17 @@ class Transform { |
// results stream. |
if (node == null) throw new MissingInputException(id); |
- // Keep track of which assets this transform depends on. |
- _inputs.add(node); |
- return node.asset; |
+ // If the asset node is found, wait until its contents are actually |
+ // available before we return them. |
+ return node.whenAvailable.then((asset) { |
+ _inputs.add(node); |
+ return asset; |
+ }).catchError((error) { |
+ if (error is! AssetNotFoundException || error.id != id) throw error; |
+ // If the node was removed before it could be loaded, treat it as though |
+ // it never existed and throw a MissingInputException. |
+ throw new MissingInputException(id); |
+ }); |
}); |
} |