-
Notifications
You must be signed in to change notification settings - Fork 221
Closed
Labels
Description
Expected behavior
After an idle_in_transaction_session_timeout, the used connection will be working properly when used again from the pool.
Actual behavior
After a statement timeout in transaction, the used connection will be "broken" and new queries will not work. The error-message is Client has encountered a connection error and is not queryable
Steps to reproduce
I've added a test-case to my project fork
Environment
- Version of pg-promise: 10.2.1
- OS type (Linux/Windows/Mac): Windows 10
- Version of Node.js: 12.12.0
Related
- Stackoverflow: How to handle idle_in_transaction_session_timeout?
- similar issue: Statement timeout in transaction returns a broken connection to the pool #566
Notes
I thought that adding another check to isConnectivityError for code 25P03 (see postgres error codes) should work, but it does not. In this case the err parameter has no code property, but a message string.
A nasty workaround for now is to check this message string:
if (!code && err.message && typeof err.message === 'string') {
if (err.message.includes('is not queryable')) return true;
}