From a8441961585849fde21e23c883d50553c718b259 Mon Sep 17 00:00:00 2001 From: Greg Rychlewski Date: Sat, 14 Oct 2023 16:22:19 -0400 Subject: [PATCH] trap exits --- lib/myxql/connection.ex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/myxql/connection.ex b/lib/myxql/connection.ex index 408cfa3..111dc50 100644 --- a/lib/myxql/connection.ex +++ b/lib/myxql/connection.ex @@ -18,6 +18,9 @@ defmodule MyXQL.Connection do @impl true def connect(opts) do + # Trap exits so that DBConnection calls `disconnect` on unexpected shutdowns + Process.flag(:trap_exit, true) + prepare = Keyword.get(opts, :prepare, :named) ping_timeout = Keyword.get(opts, :ping_timeout, 15_000) config = Client.Config.new(opts)