From 364295c7a92910ce35d7c8902dcf974806cdd224 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 22 Feb 2021 10:47:17 +0100 Subject: [PATCH] don't throw when container is already disposed, just dispose immediately --- src/utils/Disposables.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/Disposables.js b/src/utils/Disposables.js index 8bb24843..b63cba85 100644 --- a/src/utils/Disposables.js +++ b/src/utils/Disposables.js @@ -32,12 +32,14 @@ export class Disposables { } track(disposable) { - if (this.isDisposed) { - throw new Error("Already disposed, check isDisposed after await if needed"); - } if (!isDisposable(disposable)) { throw new Error("Not a disposable"); } + if (this.isDisposed) { + console.warn("Disposables already disposed, disposing new value"); + disposeValue(disposable); + return disposable; + } this._disposables.push(disposable); return disposable; }