From e52ba6830358e3901afab4534ef13d1706e60b1f Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 22 Oct 2026 16:24:47 +0400 Subject: [PATCH] fix(http): make Hackney use HTTP/1.1 only Hackney 4 negotiates HTTP/2 and shares one connection per host. The media proxy closes a response with :hackney.close/1, which stops the whole connection, so parallel downloads from one host broke each other. --- changelog.d/hackney-http1.fix | 1 + config/config.exs | 4 ++++ test/pleroma/http/adapter_helper/hackney_test.exs | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 changelog.d/hackney-http1.fix diff --git a/changelog.d/hackney-http1.fix b/changelog.d/hackney-http1.fix new file mode 100644 index 000000000..a657ed2b0 --- /dev/null +++ b/changelog.d/hackney-http1.fix @@ -0,0 +1 @@ +Hackney: use HTTP/1.1 only, so closing one media proxy response no longer breaks other downloads from the same host \ No newline at end of file diff --git a/config/config.exs b/config/config.exs index e2c110689..ec176df1d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -163,6 +163,10 @@ config :mime, :types, %{ config :tesla, adapter: Tesla.Adapter.Hackney +# Hackney 4 shares one HTTP/2 connection per host, and closing one response +# (as the media proxy does) stops it for every other stream on it. +config :hackney, default_protocols: [:http1] + # Configures http settings, upstream proxy etc. config :pleroma, :http, proxy_url: nil, diff --git a/test/pleroma/http/adapter_helper/hackney_test.exs b/test/pleroma/http/adapter_helper/hackney_test.exs index 22fcc93d1..2bda8165c 100644 --- a/test/pleroma/http/adapter_helper/hackney_test.exs +++ b/test/pleroma/http/adapter_helper/hackney_test.exs @@ -13,6 +13,12 @@ defmodule Pleroma.HTTP.AdapterHelper.HackneyTest do {:ok, uri: uri} end + # Hackney 4 shares one HTTP/2 connection per host, and closing a response + # stops that connection for every stream on it. + test "Hackney only speaks HTTP/1.1" do + assert :hackney_util.default_protocols() == [:http1] + end + describe "options/2" do setup do: clear_config([:http, :adapter], a: 1, b: 2)