remove double decrement counters

This commit is contained in:
Nour Alharithi
2023-11-15 11:05:17 -08:00
parent 0a5c11713b
commit c53f5d6672

View File

@@ -155,8 +155,6 @@ async function main() {
// Handle disconnection // Handle disconnection
ws.on('close', () => { ws.on('close', () => {
wsConnectionsGauge.dec();
// Clear any existing intervals and timeouts // Clear any existing intervals and timeouts
clearInterval(pingIntervalId); clearInterval(pingIntervalId);
clearTimeout(pongTimeoutId); clearTimeout(pongTimeoutId);
@@ -167,16 +165,11 @@ async function main() {
subscribedChannels.delete(channel); subscribedChannels.delete(channel);
} }
}); });
});
ws.on('disconnect', () => {
console.log('Client disconnected');
wsConnectionsGauge.dec(); wsConnectionsGauge.dec();
}); });
ws.on('error', (error) => { ws.on('error', (error) => {
console.error('Socket error:', error); console.error('Socket error:', error);
wsConnectionsGauge.dec();
}); });
}); });