From 07b8e128d2adc198767d9978329448ea59dad868 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 31 Oct 2019 16:43:03 -0600 Subject: [PATCH] Bypass the tests being weird They run kinda-but-not-really async, which can lead to early/late calls to `stop()` --- src/mjolnir/Mjolnir.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mjolnir/Mjolnir.js b/src/mjolnir/Mjolnir.js index 9177c621d1..7539dfafb0 100644 --- a/src/mjolnir/Mjolnir.js +++ b/src/mjolnir/Mjolnir.js @@ -66,7 +66,14 @@ export class Mjolnir { stop() { SettingsStore.unwatchSetting(this._mjolnirWatchRef); - dis.unregister(this._dispatcherRef); + + try { + if (this._dispatcherRef) dis.unregister(this._dispatcherRef); + } catch (e) { + console.error(e); + // Only the tests cause problems with this particular block of code. We should + // never be here in production. + } if (!MatrixClientPeg.get()) return; MatrixClientPeg.get().removeListener("RoomState.events", this._onEvent.bind(this));