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
pool.connect() waits forever #2338
Comments
Did you end up solving this? I'm facing a similar issue with RDS + |
I don't know if it's the same issue but I just ran into this today with pg version 7.12.1:
Nothing else is different -- I can downgrade/upgrade nodejs and restart my app to resolve/reproduce this issue. However, after I upgraded to pg version 8.4.1, it's working with both node 12.19.0 and 14.13.1:
This is all on Ubuntu 20.04 LTS. |
Yeah pg<=8.0 is not compatible with node>=14 |
Just bump your version to |
I am still having the same issue |
I have the same issue with const { Client } = require('pg');
exports.handler = async(event, context) => {
context.callbackWaitsForEmptyEventLoop = true;
try {
console.log(`Nodejs ${process.version}`)
const client = new Client({
connectionTimeoutMillis: 500
});
console.log("connecting...");
await client.connect();
console.log("connected");
const res = await client.query('SELECT NOW() as result');
console.log(res.rows[0].result);
await client.end();
console.log("done");
}
catch (e) {
console.log(e);
}
return {statusCode: 200, body: "ok"};
}; Results in
Executing the exact same code with a Node.js 12.x environment works just fine:
Everything works fine on a local machine with Node.js 14.x so there must be something special about the AWS lambda environment. |
@henriksjostrom If you're on the latest version and the connection is timing out on AWS then it's probably a firewall / security group issue. Also, you do not need |
I fail to see the connection between the runtime version (12 vs 14) and security groups. Besides that, the lambda in my example has an All/All/0.0.0.0/0 security group attached. |
anyone able to fix this? or any suggestions. |
I had the problem with "pg": "^8.6.0", "pg-pool": "^1.6.0", node14 and pg11 Updating pg-pool to 3.4.1 fixed the issue |
Hi, So i have chased this issue for a day now solid... AWS SAM node@14 Not specifically Pool, both Pool and Client expiring. Now i am using this through an MVC stack built for lambda (cerberus-mvc) and the issue i get with pg timing out on the pg middleware (which loads it from service) is actually due to where we require pg in the system. If i run node 14 on SAM i can only const pg = require('pg') from the handler file and pass it in to the stack.... if i try to load it in the middleware which is a file further down the trace, it loads fine but i get timeouts. Load it in the controller and its fine. My initial thought was that is was due to an async/await/promise issue, but its not. It is purely where we load the dependency. Doesn't matter what options you send in to pg when using, doesn't matter what version of db you connect to, works totally fine on node 10 and 12 but pg connections timeout on 14 if the require('pg') is anywhere but the handler or the controller. Clearly this is going to be a loading issue on the dep, somethings not ready somehow, but its only specific to node 14 on AWS SAM (maybe online in lambda too). I am hoping a pg or node up version will solve this, i will continue to use node 12 until 16 is out now (14 broke a lot i hear). So this is here to help me when i come looking again or if anyone else has this issue, try moving the dep require to the root file handler if your lambdas are more complicated than a single script. |
When listing the node versions, I noticed that I was forever waiting for pool.connect() to process.
My environment is as follows.
Just in case, I tried to match the pg version to 7.3.3, but the result did not change.
The contents of console.log (config) are as follows
I'm using Postgres 11.8 on AWS but I don't think it's a network issue as I can do the DB connection itself.
The text was updated successfully, but these errors were encountered: