Skip to content
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

"TimeoutError: Knex: Timeout acquiring a connection" when using with Node 14 #2849

Closed
iamacup opened this issue Apr 28, 2020 · 2 comments · Fixed by #2862
Closed

"TimeoutError: Knex: Timeout acquiring a connection" when using with Node 14 #2849

iamacup opened this issue Apr 28, 2020 · 2 comments · Fixed by #2862

Comments

@iamacup
Copy link
Contributor

iamacup commented Apr 28, 2020

At the moment, running knex/postgres on node:14.x using @keystonejs/adapter-knex@9.0.3 will not connect to a database because of a dependency on pg 7.x which does not work with node:14.x

knex/knex#3831 (comment)
brianc/node-postgres#2180

Knex 0.21.1 currently depends on pg 8.0.3 which fixes this issue

Suggested fix

bump versions in @keystonejs/adapter-knex: https://github.com/keystonejs/keystone/blob/master/packages/adapter-knex/package.json

"knex": "^0.20.6" => "knex": "^0.21.1"
"pg": "^7.17.0" => "pg": "^8.0.3"

There are a number of changes detailed here for 7.x to 8.x - https://node-postgres.com/announcements, but it looks like the only large one is:

Now we will use the default ssl options to tls.connect which includes rejectUnauthorized being enabled. This means your connection attempt may fail if you are using a self-signed cert. This makes pg a bit more secure "out of the box" while still enabling you to opt in to the old behavior.

Temporary fix

Using yarn resolutions to force versions on node:14.x:

  "resolutions": {
    "@keystonejs/adapter-knex/knex": "0.21.1",
    "@keystonejs/adapter-knex/pg": "8.0.3"
  }
@andyfcx
Copy link

andyfcx commented May 5, 2020

Had this problem too.

@tomasztunik
Copy link
Contributor

tomasztunik commented May 6, 2020

Thanks for sharing @iamacup - was starting to pull my hair out on this one! The error message was not really helpful. Adding full error message I received to improve searchability on this one:

Keystone error:

Could not connect to database:

Knex error:

Error: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants