From 27d99320182b582b3fa249da2aae99d56a5a16e3 Mon Sep 17 00:00:00 2001 From: Elin Angelow Date: Wed, 12 Jun 2024 08:36:53 +0300 Subject: [PATCH] fix: logging + memory leakage --- lib/logger.js | 7 ++++--- lib/wss.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 611bace..48299a1 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -42,15 +42,15 @@ const Logger = ({ } add(arg) { const {name, fn} = arg; - this.log('debug', 'Add', name); + this.log('debug', 'Logger', 'Add', name); super.add(arg); } remove(data) { - this.log('debug', 'Remove', data.name); + this.log('debug', 'Logger', 'Remove', data.name); super.remove(data); } async send(data) { - this.log('debug', 'Send', { + this.log('debug', 'Logger', 'Send', { id: data.id, method: data.method, caller: data?.meta?.caller, @@ -74,6 +74,7 @@ const Logger = ({ } catch (e) { this.log( 'error', + 'Logger', 'Notify', e?.error?.stack || e?.stack || e, args diff --git a/lib/wss.js b/lib/wss.js index e8d81af..0a2fb03 100644 --- a/lib/wss.js +++ b/lib/wss.js @@ -170,7 +170,7 @@ const Wss = ({ }) { // maybe reject all requests made on this connection wsClient.on('close', async() => { - this.remove(connectionId + '.write'); + this.remove({name: connectionId + '.write'}); const conn = this.connections.get(connectionId); try { await this.notify({