ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix memory leak for user notifications
Chocobozzzad9c6fe49495
diff --git a/server/core/lib/peertube-socket.ts b/server/core/lib/peertube-socket.tsindex 4beb65dda2..932269bb86 100644--- a/server/core/lib/peertube-socket.ts+++ b/server/core/lib/peertube-socket.ts@@ -40,7 +40,14 @@ class PeerTubeSocket {socket.on('disconnect', () => {logger.debug('User %d disconnected from SocketIO notifications.', userId)- this.userNotificationSockets[userId] = this.userNotificationSockets[userId].filter(s => s !== socket)+ const remaining = this.userNotificationSockets[userId]?.filter(s => s !== socket)++ // Don't keep an empty array around forever: it would leak one entry per user that ever connected+ if (!remaining || remaining.length === 0) {+ delete this.userNotificationSockets[userId]+ } else {+ this.userNotificationSockets[userId] = remaining+ }})})