Do not allow exceptions escape when closing broken connection #384
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses an issue I hit while running my server app in Docker (Swarm). Postgres was also running in the same swarm.
I was getting a "connection reset by peer" errors after a few minutes of idle operation, which seemed like were being handled by the library.
But trying to establish a new connection always resulted in a crash of my up with Unhandled exception saying "connection reset by peer" (again).
I tried to understand what's the best way to handle it inside the lib but it's still unclear to me where exactly it originates from.
The only thing that worked is adding
try-catch
in the_close
method and silencing the error, which seems reasonable.Note: The lib does throw
PgException
(which wraps the originalSocketError
) on a call toexecute
and I tried catching it, and re-creating the connection. But theSocketError
reappears as unhandled later, after callingopen
and crashes the app completely.