Skip to content

Calling connection.release() outputs to console #706

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

Closed
nibblesnbits opened this issue Jan 14, 2014 · 12 comments
Closed

Calling connection.release() outputs to console #706

nibblesnbits opened this issue Jan 14, 2014 · 12 comments

Comments

@nibblesnbits
Copy link

After starting to use connection pooling in my server I noticed that every time I close a connection using .release() I get the following message in my output:

Calling conn.end() to release a pooled connection is deprecated. In next version calling conn.end() will be restored to default conn.end() behavior. Use conn.re lease() instead.

This is filling up my output logs. I should be able to silence this sort of thing.

@felixge
Copy link
Collaborator

felixge commented Jan 14, 2014

Have you tried using conn.release() instead?

@felixge
Copy link
Collaborator

felixge commented Jan 14, 2014

Ah wait, you're saying you're using release() already? If that's the case something is broken, needs a patch.

@nibblesnbits
Copy link
Author

Yes, I'm using conn.release() like this:

`var pool = mysql.createPool({
host: config.server,
user: config.user,
password: config.password,
database: config.db
});
pool.getConnection(function(err, connection) {
// do my stuff
connection.release();
});

@dougwilson
Copy link
Member

What version of this module are you using? The current version v2.0.0 definitely does not print that if you call connection.release() only if you call connection.end() on a pooled connection, so perhaps you have a .end() call somewhere you are not seeing? The following will point to the call. If you are making a .release() call at that point, please paste the generated stack trace:

(function (pc) {
  var end = pc.end;
  pc.end = function () { console.warn(new Error().stack); return end.apply(this, arguments); };
}(require('mysql/lib/PoolConnection'));

@dougwilson
Copy link
Member

Another way to get the trace is at the beginning of your server, do something like console.warn = console.trace which will change warns into traces, as the message you are seeing uses warn.

@nibblesnbits
Copy link
Author

I'm using version 2.0.0-rc1. Was it present in that version?

@dougwilson
Copy link
Member

Nope. Please try one of the options above to trace it back. If it actually traces back to a .release() call in your code, please paste the trace here so we can see what within this library is calling the deprecated .end().

@nibblesnbits
Copy link
Author

(embarassed)

We can close this issue. I found a hidden call to .end() deep in my code. Sorry for the worry.

@dougwilson
Copy link
Member

No problem. It can be hard to find it easily. Glad the trace helped you pinpoint it.

@sidorares
Copy link
Member

@dougwilson - there is console.trace() which does the same as console.warn(new Error().stack) - https://github.com/joyent/node/blob/master/lib/console.js#L88

@dougwilson
Copy link
Member

Thanks, @sidorares, but my comment after that was to do console.warn = console.trace.

@sidorares
Copy link
Member

oops, my bad, sorry - missed that next comment

dveeden pushed a commit to dveeden/mysql that referenced this issue Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants