From de83f735eae5a6924aea54b3f9611b9558f8ff3b Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Tue, 8 Feb 2022 20:29:54 -0500 Subject: [PATCH] memory leak fixes --- lib/tasks/conference.js | 2 +- lib/tasks/dial.js | 5 ++++ lib/utils/place-outdial.js | 1 + package-lock.json | 58 +++++++++++++++++++------------------- package.json | 2 +- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/lib/tasks/conference.js b/lib/tasks/conference.js index a52af732..40ab7ce9 100644 --- a/lib/tasks/conference.js +++ b/lib/tasks/conference.js @@ -453,7 +453,7 @@ class Conference extends Task { this._playSession = null; break; } - } while (!this.killed && !this.conf_hold_status === 'hold'); + } while (!this.killed && this.conf_hold_status !== 'hold'); } /** diff --git a/lib/tasks/dial.js b/lib/tasks/dial.js index f55099a5..a1e3649b 100644 --- a/lib/tasks/dial.js +++ b/lib/tasks/dial.js @@ -382,7 +382,9 @@ class TaskDial extends Task { sd .on('callCreateFail', () => { + clearTimeout(this.timerRing); this.dials.delete(sd.callSid); + sd.removeAllListeners(); if (this.dials.size === 0 && !this.sd) { this.logger.debug('Dial:_attemptCalls - all calls failed after call create err, ending task'); this.kill(cs); @@ -424,6 +426,7 @@ class TaskDial extends Task { }) .on('accept', async() => { this.logger.debug(`Dial:_attemptCalls - we have a winner: ${sd.callSid}`); + clearTimeout(this.timerRing); try { await this._connectSingleDial(cs, sd); } catch (err) { @@ -432,7 +435,9 @@ class TaskDial extends Task { }) .on('decline', () => { this.logger.debug(`Dial:_attemptCalls - declined: ${sd.callSid}`); + clearTimeout(this.timerRing); this.dials.delete(sd.callSid); + sd.removeAllListeners(); if (this.dials.size === 0 && !this.sd) { this.logger.debug('Dial:_attemptCalls - all calls failed after decline, ending task'); this.kill(cs); diff --git a/lib/utils/place-outdial.js b/lib/utils/place-outdial.js index 7f415f58..e0590f9d 100644 --- a/lib/utils/place-outdial.js +++ b/lib/utils/place-outdial.js @@ -215,6 +215,7 @@ class SingleDialer extends Emitter { if (this.confirmHook) this._executeApp(this.confirmHook); else this.emit('accept'); } catch (err) { + this.inviteInProgress = null; const status = {callStatus: CallStatus.Failed}; if (err instanceof SipError) { status.sipStatus = err.status; diff --git a/package-lock.json b/package-lock.json index 211c28dc..5c59e19b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@jambonz/db-helpers": "^0.6.16", "@jambonz/http-health-check": "^0.0.1", "@jambonz/mw-registrar": "^0.2.1", - "@jambonz/realtimedb-helpers": "^0.4.19", + "@jambonz/realtimedb-helpers": "^0.4.21", "@jambonz/stats-collector": "^0.1.6", "@jambonz/time-series": "^0.1.6", "aws-sdk": "^2.1060.0", @@ -546,16 +546,16 @@ } }, "node_modules/@jambonz/realtimedb-helpers": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.4.19.tgz", - "integrity": "sha512-wEc7OXogQ5SZ9mgLNxviBNY0WvUKGGztyDzze3oi44edsZp0vNneVHUmdZuDzuDvUMBqsvCa0fvri8LGaxovlw==", + "version": "0.4.21", + "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.4.21.tgz", + "integrity": "sha512-+MlCe+eY0by57CxqSLk03rl0frrJV6J16DErvIxbmkytOUWlEZkBxwxsoPjErWVom7hNyKEnCmZXMIHT2Kfocg==", "dependencies": { "@google-cloud/text-to-speech": "^3.4.0", "@jambonz/promisify-redis": "^0.0.6", "aws-sdk": "^2.1060.0", "bent": "^7.3.12", "debug": "^4.3.3", - "microsoft-cognitiveservices-speech-sdk": "^1.19.0", + "microsoft-cognitiveservices-speech-sdk": "^1.20.0", "redis": "^3.1.2" } }, @@ -3506,9 +3506,9 @@ } }, "node_modules/microsoft-cognitiveservices-speech-sdk": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.19.0.tgz", - "integrity": "sha512-FYyXdJcTLX8Iunnn9XHzTfR+43YdEZn1q89KX6Vzqtaa4hz/LemdC9Zni50VIfkXMNtq2sJFYf5wKXvxm1wQHA==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.20.0.tgz", + "integrity": "sha512-/KWNHQb36nhIkBr6HClh+T+gHicgmC5JKJhCnQmL6XGAAndLtew0aRbh7cMK10IFNTgozGKiejhrfnwiYH3IBA==", "hasInstallScript": true, "dependencies": { "agent-base": "^6.0.1", @@ -3520,7 +3520,7 @@ "simple-lru-cache": "0.0.2", "url-parse": "^1.4.7", "uuid": "^8.3.0", - "ws": "^7.3.1" + "ws": "^7.5.6" } }, "node_modules/microsoft-cognitiveservices-speech-sdk/node_modules/https-proxy-agent": { @@ -5114,9 +5114,9 @@ } }, "node_modules/url-parse": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.3.tgz", - "integrity": "sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.4.tgz", + "integrity": "sha512-ITeAByWWoqutFClc/lRZnFplgXgEZr3WJ6XngMM/N9DMIm4K8zXPCZ1Jdu0rERwO84w1WC5wkle2ubwTA4NTBg==", "dependencies": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -5343,9 +5343,9 @@ } }, "node_modules/ws": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz", - "integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", + "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", "engines": { "node": ">=8.3.0" }, @@ -5876,16 +5876,16 @@ } }, "@jambonz/realtimedb-helpers": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.4.19.tgz", - "integrity": "sha512-wEc7OXogQ5SZ9mgLNxviBNY0WvUKGGztyDzze3oi44edsZp0vNneVHUmdZuDzuDvUMBqsvCa0fvri8LGaxovlw==", + "version": "0.4.21", + "resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.4.21.tgz", + "integrity": "sha512-+MlCe+eY0by57CxqSLk03rl0frrJV6J16DErvIxbmkytOUWlEZkBxwxsoPjErWVom7hNyKEnCmZXMIHT2Kfocg==", "requires": { "@google-cloud/text-to-speech": "^3.4.0", "@jambonz/promisify-redis": "^0.0.6", "aws-sdk": "^2.1060.0", "bent": "^7.3.12", "debug": "^4.3.3", - "microsoft-cognitiveservices-speech-sdk": "^1.19.0", + "microsoft-cognitiveservices-speech-sdk": "^1.20.0", "redis": "^3.1.2" } }, @@ -8212,9 +8212,9 @@ "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, "microsoft-cognitiveservices-speech-sdk": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.19.0.tgz", - "integrity": "sha512-FYyXdJcTLX8Iunnn9XHzTfR+43YdEZn1q89KX6Vzqtaa4hz/LemdC9Zni50VIfkXMNtq2sJFYf5wKXvxm1wQHA==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.20.0.tgz", + "integrity": "sha512-/KWNHQb36nhIkBr6HClh+T+gHicgmC5JKJhCnQmL6XGAAndLtew0aRbh7cMK10IFNTgozGKiejhrfnwiYH3IBA==", "requires": { "agent-base": "^6.0.1", "asn1.js-rfc2560": "^5.0.1", @@ -8225,7 +8225,7 @@ "simple-lru-cache": "0.0.2", "url-parse": "^1.4.7", "uuid": "^8.3.0", - "ws": "^7.3.1" + "ws": "^7.5.6" }, "dependencies": { "https-proxy-agent": { @@ -9476,9 +9476,9 @@ } }, "url-parse": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.3.tgz", - "integrity": "sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.4.tgz", + "integrity": "sha512-ITeAByWWoqutFClc/lRZnFplgXgEZr3WJ6XngMM/N9DMIm4K8zXPCZ1Jdu0rERwO84w1WC5wkle2ubwTA4NTBg==", "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -9662,9 +9662,9 @@ } }, "ws": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz", - "integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", + "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", "requires": {} }, "xml2js": { diff --git a/package.json b/package.json index 77ef48cf..503bd65a 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@jambonz/db-helpers": "^0.6.16", "@jambonz/http-health-check": "^0.0.1", "@jambonz/mw-registrar": "^0.2.1", - "@jambonz/realtimedb-helpers": "^0.4.19", + "@jambonz/realtimedb-helpers": "^0.4.21", "@jambonz/stats-collector": "^0.1.6", "@jambonz/time-series": "^0.1.6", "aws-sdk": "^2.1060.0",