-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
(node) Possible eventEmitter memory leak detected. 11 listeners added. #86
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
Comments
It's part of a script that uses lots of async callbacks. Could I be writing too quickly/often to the database? And which uses long-stack-traces https://github.com/tlrobinson/long-stack-traces. Could that library be causing the issue ( tlrobinson/long-stack-traces#5 ) |
This is totally normal if the number of event listeners is greater than 10. Maybe you should use |
Is an event listener being created each time I run a command that takes a ~ J (via phone) |
can I get code to reproduce (an entire executable script from top to bottom minus connection info is best) this and a version of node, version of node-postgres, and if you are using pure-javascript or native bindings? I've done a decent amount of load testing and never seen max connection listeners exceeded. More generally to answer your question, there should be no place within node-postgres where event listeners are attached & detached multiple times on a query-by-query basis. the |
Unfortunately, I stopped using the plugin that exposed these warnings, so I'm not actually able to give better code examples. Luckily, it still sounds like this might have been an issue from something else, and not a PG bug. |
I had the same issue. I figured out it was caused by doing
but never doing
I think in this case |
Hello. var exports = module.exports = {};
var pg = require('pg');
var connectionString = "postgres://postgres:[email protected]:5432/postgres";
var client = new pg.Client(connectionString);
var connected = false;
function connect() {
client.connect(function (err) {
if (err) {
connected = false;
}
else {
connected = true;
}
});
}
exports.Insert = function (packet) {
if (!connected) connect();
var tablename = packet.msgExchange.split('-')[1];
client.query('CREATE TABLE IF NOT EXISTS ' + tablename + '(msgid serial NOT NULL, msgtxt character varying, "msgDateTime" timestamp with time zone DEFAULT now(), "msgChannel" character varying, "msgClient" character varying, CONSTRAINT ' + tablename + '_pkey PRIMARY KEY (msgid)) WITH ( OIDS=FALSE )');
for (var i = 0; i < packet.msgChannel.length; i++) {
client.query('INSERT INTO '+ tablename + '(msgTxt, "msgDateTime", "msgChannel", "msgClient") VALUES ($1, $2, $3, $4)', [packet.msgTxt.toString(), packet.msgDateTime, packet.msgChannel[i], packet.msgClient.toString()]);
}
} I have created separate file to use Insert function. When I call Insert function inside the for loop, It is giving me same error given by @jfeldstein. |
* Add failing test for correct removal from checkout queue on timeout * Remove timed-out checkouts from queue correctly Fixes #85.
Getting this, with a stack trace back into pg. Any tips?
The text was updated successfully, but these errors were encountered: