-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove close listener before next startStreamProcess loop #1038
Conversation
This cause memory leak during fast publishing when leveldb store is used ```VM38 warning.js:27 (node:2090114) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [MqttClient]. Use emitter.setMaxListeners() to increase limit```
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1038 +/- ##
=======================================
Coverage 93.63% 93.63%
=======================================
Files 8 8
Lines 942 943 +1
Branches 249 249
=======================================
+ Hits 882 883 +1
Misses 60 60
☔ View full report in Codecov by Sentry. |
I can't tell much about if this is implemented correctly, but I know it solves the same problem for me. |
@rtuin can you explain the problem in a bit more detail? There is a memory leak when publishing in general or just when using leveldb store? |
@YoDaMa I ran into this issue while writing a simple load generator to run some tests.
Let me elaborate with a code sample. Hope this helps! var mqtt = require('async-mqtt');
const fs = require('fs');
const runAsync = async () => {
var client = await mqtt.connect('mqtts://my-host.domain', {
key: fs.readFileSync('client.key'),
cert: fs.readFileSync('client.crt'),
ca: [ fs.readFileSync('ca.crt') ]
});
let count = 0;
const publishes = [];
while (count++ < 100000) {
publishes.push(() => {
return client.publish('my-topic', 'Hello mqtt' + count, {qos: 2});
});
}
await Promise.allConcurrent(1000)(publishes).then((x) => {
console.log(x);
});
return await client.end();
};
runAsync(); |
@patrykwegrzyn Can you sync with master so I can merge this? |
If you wish to continue with this PR please remember to change destination branch from |
Supersided by #1759 |
This cause memory leak during fast publishing when leveldb store is used
VM38 warning.js:27 (node:2090114) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [MqttClient]. Use emitter.setMaxListeners() to increase limit