Fix "Possible EventEmitter memory leak detected. 1001 drain listeners added to [Socket]" warning. #9822

This commit is contained in:
Koen Kanters 2021-11-29 17:49:44 +01:00
parent 82f5ddb748
commit c2d9ffa7ad
2 changed files with 2 additions and 0 deletions

View File

@ -69,6 +69,7 @@ export default class MQTT {
return new Promise((resolve, reject) => {
this.client = mqtt.connect(mqttSettings.server, options);
this.client.setMaxListeners(0);
const onConnect = this.onConnect;
this.client.on('connect', async () => {

View File

@ -6,6 +6,7 @@ const mock = {
subscribe: jest.fn(),
reconnecting: false,
on: jest.fn(),
setMaxListeners: jest.fn(),
};
const mockConnect = jest.fn().mockReturnValue(mock);