fix redis listener leak in StreamingApiServerService.ts
This commit is contained in:
parent
4e609478f8
commit
168a364162
1 changed files with 5 additions and 2 deletions
|
|
@ -201,10 +201,12 @@ export class StreamingApiServerService {
|
|||
|
||||
const globalEv = new EventEmitter();
|
||||
|
||||
this.redisForSub.on('message', (_: string, data: string) => {
|
||||
const onRedis = (_: string, data: string) => {
|
||||
const parsed = JSON.parse(data);
|
||||
globalEv.emit('message', parsed);
|
||||
});
|
||||
};
|
||||
|
||||
this.redisForSub.on('message', onRedis);
|
||||
|
||||
this.#wss.on('connection', async (connection: WebSocket.WebSocket, request: http.IncomingMessage, ctx: {
|
||||
stream: MainStreamConnection,
|
||||
|
|
@ -235,6 +237,7 @@ export class StreamingApiServerService {
|
|||
connection.once('close', () => {
|
||||
ev.removeAllListeners();
|
||||
stream.dispose();
|
||||
this.redisForSub.off('message', onRedis);
|
||||
globalEv.off('message', onRedisMessage);
|
||||
this.#connections.delete(connection);
|
||||
if (userUpdateIntervalId) clearInterval(userUpdateIntervalId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue