From f604f9e47061b9d47c1bb62cc7aaf44fabdf69b3 Mon Sep 17 00:00:00 2001
From: Alexander Strizhakov <alex.strizhakov@gmail.com>
Date: Fri, 21 Feb 2020 14:33:55 +0300
Subject: [PATCH] hackney pool timeout

---
 lib/pleroma/http/connection.ex | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/pleroma/http/connection.ex b/lib/pleroma/http/connection.ex
index 85918341a..e2d7afbbd 100644
--- a/lib/pleroma/http/connection.ex
+++ b/lib/pleroma/http/connection.ex
@@ -33,8 +33,14 @@ defmodule Pleroma.HTTP.Connection do
   end
 
   defp pool_timeout(opts) do
-    timeout =
-      Config.get([:pools, opts[:pool], :timeout]) || Config.get([:pools, :default, :timeout])
+    {config_key, default} =
+      if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Gun do
+        {:pools, Config.get([:pools, :default, :timeout])}
+      else
+        {:hackney_pools, 10_000}
+      end
+
+    timeout = Config.get([config_key, opts[:pool], :timeout], default)
 
     Keyword.merge(opts, timeout: timeout)
   end