Skip to content

Commit

Permalink
Trap exits from connect callback (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-rychlewski authored Oct 14, 2023
1 parent cb6bdbc commit c8edce4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/postgrex/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ defmodule Postgrex.Protocol do
{:ok, state}
| {:error, Postgrex.Error.t() | %DBConnection.ConnectionError{}}
def connect(opts) do
# Trap exits so that DBConnection calls `disconnect` on unexpected shutdowns
Process.flag(:trap_exit, true)

endpoints = endpoints(opts)

timeout = opts[:timeout] || @timeout
Expand Down

0 comments on commit c8edce4

Please sign in to comment.