From 2a1407a531e74eaea8a729cbd66d8f33d9d5f661 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 27 Jan 2020 15:36:12 -0700 Subject: [PATCH] Add more logging to settings watchers To try and track leaks versus spam. Fixes https://github.com/vector-im/riot-web/issues/12094 (it's not leaking, probably) --- src/settings/SettingsStore.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/settings/SettingsStore.js b/src/settings/SettingsStore.js index 9501bac205..b1d61197a0 100644 --- a/src/settings/SettingsStore.js +++ b/src/settings/SettingsStore.js @@ -145,7 +145,7 @@ export default class SettingsStore { callbackFn(originalSettingName, changedInRoomId, atLevel, newValAtLevel, newValue); }; - console.log(`Starting watcher for ${settingName}@${roomId || ''}`); + console.log(`Starting watcher for ${settingName}@${roomId || ''} as ID ${watcherId}`); SettingsStore._watchers[watcherId] = localizedCallback; defaultWatchManager.watchSetting(settingName, roomId, localizedCallback); @@ -159,8 +159,12 @@ export default class SettingsStore { * to cancel. */ static unwatchSetting(watcherReference) { - if (!SettingsStore._watchers[watcherReference]) return; + if (!SettingsStore._watchers[watcherReference]) { + console.warn(`Ending non-existent watcher ID ${watcherReference}`); + return; + } + console.log(`Ending watcher ID ${watcherReference}`); defaultWatchManager.unwatchSetting(SettingsStore._watchers[watcherReference]); delete SettingsStore._watchers[watcherReference]; }