Skip to content

Commit

Permalink
Fix "Possible EventEmitter memory leak detected. 1001 drain listeners…
Browse files Browse the repository at this point in the history
… added to [Socket]" warning. #9822
  • Loading branch information
Koenkk committed Nov 29, 2021
1 parent 82f5ddb commit c2d9ffa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
1 change: 1 addition & 0 deletions test/stub/mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const mock = {
subscribe: jest.fn(),
reconnecting: false,
on: jest.fn(),
setMaxListeners: jest.fn(),
};

const mockConnect = jest.fn().mockReturnValue(mock);
Expand Down

0 comments on commit c2d9ffa

Please sign in to comment.