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
"There is no pool defined on the current client" is a bad error message #1583
Comments
Can we outline specifically each case since they may need to be addressed separately? Starting with your list:
I use Hapijs a lot and they do a good job of configuration checking. Keep in mind w/r/t configuration validation for knex, the docs list a supported case (see below) that makes this pretty darn hard (missing configuration, though perhaps it can be deferred until a query is issued to the datbase--i.e. with a promise or callback): var knex = require('knex')({}); // configure w/ empty object
var pg = require('knex')({client: 'pg'}); // configure without connection
knex('table').insert({a: 'b'}).returning('*').toString();
pg('table').insert({a: 'b'}).returning('*').toString(); |
Here's an example of "no client key defined"
|
"There is no pool defined on the current client" gets returned for any psql error. For example, a validation UNIQUE error would return this for me. Knowing that this error is the catch all error for any error that comes from psql, I was curious if anyone had a way to step in before this error? Is there a way to log psql directly without knex failing generically ( and in this case incorrectly )? |
@gotoAndBliss this message has been changed to "Unable to acquire a connection" in 0.12 which is more indicative of the actual error. It should only occur if you have either not supplied a proper connection configuration or have already called I don't see how you'd be seeing this error if the client is properly configured. |
I'm using Knex@0.12.1 -- And can confirm it returns that same message |
@gotoAndBliss if you are on 0.12.1, the message couldn't be "There is no pool defined on the current client", that line is no longer anywhere in the codebase. Maybe run setting env to |
@tgriesser That helped me solve it. Thanks so much for your help. |
Yep! |
🎉 Kudos on picking a more descriptive error message. This should definitely help future users avoid time wasted. 👍 |
Search for this message in the issue list and you'll get quite a few issues where they ALL have entirely different source problems. Ranging from: No environment defined, bad client name, no client key defined, no connection defined, etc.
Instead we need better messages about our client, type constrained if possible. I should know when I accidentally type
pgsql
instead ofpg
orpostgres
. I should know when my configuration is missing the client key, a pretty freaking important key.The text was updated successfully, but these errors were encountered: