Browse Source

Prevent console error when a future is canceled.

From @afshin, who made the fix in #4733.
Jason Grout 7 năm trước cách đây
mục cha
commit
bce868be14
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 5 0
      packages/services/src/kernel/future.ts

+ 5 - 0
packages/services/src/kernel/future.ts

@@ -154,7 +154,12 @@ class KernelFutureHandler extends DisposableDelegate implements Kernel.IFuture {
     this._reply = Private.noOp;
     this._hooks = null;
     if (!this._testFlag(Private.KernelFutureFlag.IsDone)) {
+      // Reject the `done` promise, but catch its error here in case no one else
+      // is waiting for the promise to resolve. This prevents the error from
+      // being displayed in the console, but does not prevent it from being
+      // caught by a client who is waiting for it.
       this._done.reject(new Error('Canceled'));
+      this._done.promise.catch(() => { /* no-op */ });
     }
     super.dispose();
   }