From f885e49e34d63d70742de7d6c705bf431c86bc27 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 2 Jul 2023 01:38:49 +0200 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/servertools/classes.server.ts | 23 +++++++++++------------ ts_web/00_commitinfo_data.ts | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index c9437f2..caa158e 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@apiglobal/typedserver', - version: '2.0.60', + version: '2.0.61', description: 'easy serving of static files' } diff --git a/ts/servertools/classes.server.ts b/ts/servertools/classes.server.ts index 908e520..d1018ed 100644 --- a/ts/servertools/classes.server.ts +++ b/ts/servertools/classes.server.ts @@ -218,25 +218,24 @@ export class Server { this.httpServer.on('connection', (connection: plugins.net.Socket) => { this.socketMap.add(connection); console.log(`added connection. now ${this.socketMap.getArray().length} sockets connected.`); + const cleanListener = () => { + cleanupConnection(); + } const cleanupConnection = () => { + connection.removeListener('close', cleanListener); + connection.removeListener('error', cleanListener); + connection.removeListener('end', cleanListener); + connection.removeListener('timeout', cleanListener); if (this.socketMap.checkForObject(connection)) { this.socketMap.remove(connection); console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`); connection.destroy(); } }; - connection.on('close', () => { - cleanupConnection(); - }); - connection.on('error', () => { - cleanupConnection(); - }); - connection.on('end', () => { - cleanupConnection(); - }); - connection.on('timeout', () => { - cleanupConnection(); - }); + connection.addListener('close', cleanListener); + connection.addListener('error', cleanListener); + connection.addListener('end', cleanListener); + connection.addListener('timeout', cleanListener); }); // finally listen on a port diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index c9437f2..caa158e 100644 --- a/ts_web/00_commitinfo_data.ts +++ b/ts_web/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@apiglobal/typedserver', - version: '2.0.60', + version: '2.0.61', description: 'easy serving of static files' }