Connection terminated error with pooling
See original GitHub issueHi everybody !
I have a little problem with my code. I’m trying to request my DB to get the pseudo linked with a specific ID. I’m using the pool as recommended with the documentation but I have an error. I think I’m missing something but I don’t know why.
This is my code:
function pseudo_utilisateur(id){
return new Promise(function(resolve, reject){
let query = `SELECT pseudo FROM ${Tables.user} WHERE id = $1`;
pool.connect(function(err, client, done){
client.query(query, [id],function(err, result){
done();
if(err){
console.log(err);
reject("err");
}
else{
console.log(result);
resolve(result.rows[0].pseudo);
}
})
})
})
}
and this is the error I received:
Error: Connection terminated
at Connection.<anonymous> (E:\Cours année 2015 - 2017\Mémoire\mookup\node_modules\pg\lib\client.js:198:29)
at Object.onceWrapper (events.js:291:19)
at emitNone (events.js:86:13)
at Connection.emit (events.js:186:7)
at Socket.<anonymous> (E:\Cours année 2015 - 2017\Mémoire\mookup\node_modules\pg\lib\connection.js:78:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:189:7)
at TCP._handle.close [as _onclose] (net.js:501:12)
I have read this is a common error when someone uses the client approach. But I don’t think I close the connection before reading the results. If I have well understood, the done() method is to release the client and the result of the request is in the callback of the client. But maybe I’m wrong.
So can someone help me, please ? Thank you very much
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (3 by maintainers)
Top Results From Across the Web
Postgresql Error: connection terminated - Stack Overflow
Here's how I was able to fix it. This means that the client somehow dropped the connection before the server could finish.
Read more >1623183 - Postgres Connection termination kills services
The script got a little more complicated! The error occurs when the connection dies while the client is checked out of the pool,...
Read more >Connection Error: Connection ended unexpectedly - Render
... new database and now keep getting a connection terminated error. this ... i added the pool object and acquireConnectionTimeout . i might ......
Read more >JDBC Connection terminated error - Adobe Support Community
1. Try disabling JDBC pooling entirely. You can do this in the CF Admin by unchecking "Maintain Connections". This will keep you from...
Read more >Handling java.sql.SQLRecoverableException: Closed ...
SQLRecoverableException: Closed Connection errors ... then the database connection pool (DBCP) or C3PO (if using direct JDBC) is not able to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@JulesAU @AkhilGopan @baninaveen again, please open a new issue with reproduction code and the error you see. It doesn’t help to write on a closed issue, which the OP has closed because he has solved his own bug.
Please reeopened an issue, don’t feed a closed one.