From e39bac0b8b82e5bc5d3e6a7bd4f555cdb584c751 Mon Sep 17 00:00:00 2001 From: The Major Date: Fri, 28 Nov 2025 11:39:08 -0800 Subject: [PATCH] Make timeouts for TypeServer configurable --- lib/postgrex/type_server.ex | 9 +++++---- mix.exs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/postgrex/type_server.ex b/lib/postgrex/type_server.ex index ac4b7d081..65c4662eb 100644 --- a/lib/postgrex/type_server.ex +++ b/lib/postgrex/type_server.ex @@ -5,8 +5,6 @@ defmodule Postgrex.TypeServer do defstruct [:types, :connections, :lock, :waiting] - @timeout 60_000 - @doc """ Starts a type server. """ @@ -24,8 +22,10 @@ defmodule Postgrex.TypeServer do @spec fetch(pid) :: {:lock, reference, Postgrex.Types.state()} | :noproc | :error def fetch(server) do + timeout = Application.fetch_env!(:postgrex, :type_server_timeout) + try do - GenServer.call(server, :fetch, @timeout) + GenServer.call(server, :fetch, timeout) catch # module timed out, pretend it did not exist. :exit, {:normal, _} -> :noproc @@ -38,7 +38,8 @@ defmodule Postgrex.TypeServer do """ @spec update(pid, reference, [Postgrex.TypeInfo.t()]) :: :ok def update(server, ref, [_ | _] = type_infos) do - GenServer.call(server, {:update, ref, type_infos}, @timeout) + timeout = Application.fetch_env!(:postgrex, :type_server_timeout) + GenServer.call(server, {:update, ref, type_infos}, timeout) end def update(server, ref, []) do diff --git a/mix.exs b/mix.exs index 886524061..5f702ec2a 100644 --- a/mix.exs +++ b/mix.exs @@ -23,7 +23,7 @@ defmodule Postgrex.Mixfile do [ extra_applications: [:logger, :crypto, :ssl], mod: {Postgrex.App, []}, - env: [type_server_reap_after: 3 * 60_000, json_library: Jason] + env: [type_server_reap_after: 3 * 60_000, type_server_timeout: 60_000, json_library: Jason] ] end