From 6b3a06a8edc9fc69c178f9a76eb33f4bbbe9482b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Sun, 2 Oct 2016 21:06:10 +0100 Subject: [PATCH] Fix checkTurnServers leak on logout Remember to cancel the checkTurnServers callback when we stop the client. --- lib/client.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/client.js b/lib/client.js index d9e6f16cc..ce96b1c85 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2543,6 +2543,7 @@ MatrixClient.prototype.stopClient = function() { if (this._crypto) { global.clearInterval(this._uploadIntervalID); } + global.clearTimeout(this._checkTurnServersTimeoutID); }; function setupCallEventHandler(client) { @@ -2762,13 +2763,15 @@ function checkTurnServers(client) { }; client._turnServers = [servers]; // re-fetch when we're about to reach the TTL - setTimeout(function() { checkTurnServers(client); }, - (res.ttl || (60 * 60)) * 1000 * 0.9 - ); + client._checkTurnServersTimeoutID = + setTimeout(function() { checkTurnServers(client); }, + (res.ttl || (60 * 60)) * 1000 * 0.9 + ); } }, function(err) { console.error("Failed to get TURN URIs"); - setTimeout(function() { checkTurnServers(client); }, 60000); + client._checkTurnServersTimeoutID = + setTimeout(function() { checkTurnServers(client); }, 60000); }); }