test(http): cover the Hackney connection leak

Serve a response announcing far more than it sends, then close, and
assert the connection process is gone. Fails against stock 4.7.2 with a
conn parked in `closed` holding the bytes it read; passes against the
pinned fix.

Also stop the Hackney tests trusting proxy environment variables.
`no_proxy_env` is not a Hackney option and never was, so a proxy in the
build environment silently turned these into tunnelled requests, which
are never pooled -- exactly the shape several of them mean to exclude.
`proxy: false` is what Hackney actually reads.

That surfaced a matching bug in the reverse proxy client, which treated
`proxy: false` as "a proxy is set" and so declined to mark a pooled
bodyless response as already released.
This commit is contained in:
Lain Soykaf 2026-07-26 10:15:52 +04:00
commit 498c9ad532
No known key found for this signature in database
5 changed files with 213 additions and 4 deletions

View file

@ -149,9 +149,14 @@ defmodule Pleroma.ReverseProxy.Client.Hackney do
# checked in, and parks in `connected` with no idle timeout, so it leaks
# forever unless we stop it ourselves.
defp pooled?(opts) do
is_nil(Keyword.get(opts, :proxy)) and use_pool?(Keyword.get(opts, :pool))
no_proxy?(Keyword.get(opts, :proxy)) and use_pool?(Keyword.get(opts, :pool))
end
# Hackney reads `false` as "no proxy", same as an absent option.
defp no_proxy?(nil), do: true
defp no_proxy?(false), do: true
defp no_proxy?(_proxy), do: false
defp use_pool?(false), do: false
defp use_pool?(nil), do: Application.get_env(:hackney, :use_default_pool, true)
defp use_pool?(_pool_name), do: true