-
-
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
Crashing after database restart #2635
Comments
Hi Jonathan, your app crashes because of the uncaught exception in general. You can catch all uncaught exeptions in your application by following code.
But it is too late here for you, because in this place you should just clean up and exit. You need to catch the exception earlier, at the place where it occures, and that is on the connected client / pool client. You need to update Database class connect function last row implementation like this to catch the client's error too. Than this error would not be thrown as uncaught exception.
|
Hi @tpuza, Thanks for your explanation, I just tried it but my apps is crashing even by adding event handler in connect method
And crash |
Actualy I'am not a 100% sure, but I would not mix the async and callback and would use one or other. Try also look deeper in your code, if there is not another client call without handling the error. |
I am experiences this too, although via Is there a way to accomplish this please? Thanks in advance. |
Same issue here. I think |
I noticed this as well but only under high concurrency. I can recreate locally by killing Postgres while having a number of queries in progress. It's the same stack trace above. I suspect it's how the pool and/or clients remove/unlisten themselves when things are terminating unexpectedly but haven't found it yet. |
This suggestion fixes it: #2439 (comment) |
Hi,
I'm facing to a pretty annoying issue.
Here my connection code:
Sometimes, my database restart, and I've receive an error
error: terminating connection due to administrator command
andError: Connection terminated unexpectedly
I read a lot about this issue on this repo or internet, and I can't know why my app is exiting.
I also added on error event to my transaction
Also tried to add on error event on every query I've done
Can you help me on this point ?
"pg": "^8.7.1"
Thanks
The text was updated successfully, but these errors were encountered: