Fix a synchronous event bug in futureStream.

R=rnystrom@google.com
TBR

Review URL: https://codereview.chromium.org//68713004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/watcher@30182 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/watcher/lib/src/utils.dart b/pkgs/watcher/lib/src/utils.dart
index a64575b..a235f7d 100644
--- a/pkgs/watcher/lib/src/utils.dart
+++ b/pkgs/watcher/lib/src/utils.dart
@@ -36,9 +36,10 @@
   var controller;
 
   future = future.catchError((e, stackTrace) {
-    if (controller == null) return;
-    controller.addError(e, stackTrace);
-    controller.close();
+    // Since [controller] is synchronous, it's likely that emitting an error
+    // will cause it to be cancelled before we call close.
+    if (controller != null) controller.addError(e, stackTrace);
+    if (controller != null) controller.close();
     controller = null;
   });