-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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.on('error')
doesn’t populate client error listeners as well
#2439
Comments
That’s right – you need to add error handlers when checking clients out of the pool, in addition to the pool-level error handler, and remove them before returning clients to the pool. Correct error handling isn’t very easy with pg at the moment. |
@charmander Thanks for the quick reply. For future use, this one also work perfectly:
|
pool.on('error')
doesn’t populate client error listeners as well
I notice that @ynahmany 's comment with the solution was linked from other issues and got quite a few 👍s. I worry that the comment there:
may leave people with a poor impression of the library, while it's actually WAD. @charmander I notice you want to make this issue the "canonical" one for "error ergonomics". What options are you considering? Looking at the events on the |
One source of confusion may be that the the docs for the
AFAICT the word "idle" simply means a client not currently being (dis)connected or executing a query. The docs for the |
Correction: I now think that the two uses of the word "idle" mean the same thing, because the pool only checks out / acquires a client for the duration of query execution. |
Are you saying there is a way to unregistered listeners of events? |
This is true for |
Does anyone know how to test this? What error will trigger this new error handler? |
Just found the answer for my own question. If you start postgres with docker, start a long running query and then kill postgres with |
Hi,
I came across a strange behavior recently.
Env setup:
Linux- Ubuntu 18.
Docker - 19.06
Node and Postgres running inside docker using docker-compose.
When I manually restarted(or shut down) Postgres docker -> the Node app crashes with Error:
I configured the
on.error(callback)
listener yet I keep getting this error which causes my node application to crashThe solution was to add
on.error
to the client that is being returned from the callback above.The text was updated successfully, but these errors were encountered: