Repository navigation
Conversation
ericmj
force-pushed
the
claude/add-hex-core-adapter-id9BK
branch
from
April 13, 2026 02:22
fa2b5bc to
f470149
Compare
ericmj
force-pushed
the
claude/add-hex-core-adapter-id9BK
branch
from
October 5, 2026 16:16
98805e3 to
ec9f024
Compare
Adds scripts/vendor_mint.sh which vendors Mint and its dependency HPAX into lib/hex/mint/ with Hex.Mint.* module prefixes. The vendored code runs outside the :mint application so persistent_term keys are namespaced under :hex_mint and no application env is accessed.
Replaces :httpc with the vendored Hex.Mint.HTTP as the transport for
the :mix_hex_http adapter. Architecture follows Finch's protocol-split
strategy, adapted for Hex's no-deps constraint:
* Hex.HTTP.Pool - router + supervisor. Owns a Registry and a
DynamicSupervisor, plus an ETS table caching the ALPN-negotiated
protocol per {scheme, host, port}. First request for a host probes
with `protocols: [:http1, :http2]` and installs the result in ETS.
* Hex.HTTP.Pool.HTTP1 - pool of single-connection Worker GenServers
with checkout/checkin semantics. Default 8 workers per host
(matches former :httpc max_sessions). Idle workers auto-close
after 30s.
* Hex.HTTP.Pool.HTTP1.Worker - owns one Mint HTTP/1 connection,
handles one in-flight request at a time, translates Mint's async
message stream into a synchronous GenServer.call reply.
* Hex.HTTP.Pool.HTTP2 - :gen_statem per host (default 1 connection,
multiplexes many requests). States: :disconnected, :connecting,
:connected, :connected_read_only. Exponential backoff reconnect.
Server GOAWAY transitions to :connected_read_only so the router
can spin up a fresh connection while in-flight streams drain.
Hex.HTTP keeps its role as the :mix_hex_http behaviour and retains:
retry (with IPv4/IPv6 fallback on :nxdomain/:ehostunreach/etc),
redirect following, timeout wrapper, netrc auth, gzip decompression,
progress-callback body chunking, x-hex-message handling. Error
patterns now match %Hex.Mint.TransportError{}. Proxy config is
emitted as a per-connect Mint `:proxy` option instead of mutating
global :httpc state.
Application changes:
* Hex.HTTP.Pool added to supervision tree (before Hex.Server and
the fetcher pool).
* start_httpc/0 removed; :inets dropped from extra_applications.
* :httpc_profile removed from Hex.State.
* test/support/hexpm.ex wait_on_start uses :gen_tcp directly.
* test/hex/http_test.exs setup no longer calls :httpc.set_options;
proxy_config tests adapted to Mint :proxy tuple shape.
https://claude.ai/code/session_01DdkbbnQEW9WygTsj2Dq5KS
The previous pool design split HTTP/1 and HTTP/2 into separate modules
and probed ALPN in the caller process. That caller opened the socket,
then tried to hand it off to a worker via `controlling_process/2` — which
fails with `:not_owner` when called from anywhere except the current
socket owner. The "fix" in HTTP1.Worker.init/1 (calling
`controlling_process(conn, self())` from the worker) could never have
worked at runtime; the HTTP/2 path had the same latent bug.
Replaced the HTTP1/HTTP1.Worker/HTTP2 modules with a unified design:
* Hex.HTTP.Pool.Host (one GenServer per {scheme, host, port}) owns a
pool of Conn processes. On start it spawns two probe Conns; when the
first reports its protocol it scales up to 8 for :http1 or stays at
2 for :http2. Dispatches by least in-flight to the Conn with free
capacity; queues waiters otherwise.
* Hex.HTTP.Pool.Conn (one GenServer per Mint connection) connects
inside its own process, so the socket is owned from birth — no
controlling_process handoff ever needed. Reports negotiated protocol
and per-conn capacity (1 for HTTP/1, server's max_concurrent_streams
for HTTP/2) back to its host. Requests arrive as casts carrying the
caller's `from`; Conn replies directly to the caller and casts back
:req_done so the host decrements in-flight. Handles GOAWAY by
draining in-flight then reconnecting with exponential backoff.
* Hex.HTTP.Pool now just wires up the Registry + DynamicSupervisor and
routes requests to the Host for a given {scheme, host, port}. No
more probe phase, no ETS cache, no initial_conn plumbing.
Also fixes 1xx informational response handling in the vendored Mint
HTTP/1 module, which previously emitted `:done` and popped the request
after a 100 Continue / 103 Early Hints etc., causing the real final
response to arrive with no active request and the connection to close.
Upstream fix submitted as elixir-mint/mint#479; the vendored copy marks
the change with `# HEX PATCH` comments for easy re-application after
re-vendoring.
Conn.process_response resets accumulated headers/data on each new
`:status` so informational headers (e.g. 103 Early Hints `link:`) don't
bleed into the final response. Added bypass-backed regression tests for
100 Continue round-trip, 100 Continue with early error response, and
103 Early Hints with headers. test/mix/tasks/hex.registry_test.exs now
uses `Hex.HTTP.config/0` instead of the raw httpc-defaulting config.
Stream request bodies:
`mix hex.publish` shows an upload progress bar by wrapping the tarball
in a producer function and passing a `progress_callback`. Previously
`Hex.HTTP.build_mint_request` collected the full stream into a binary
before sending, so the callback fired at gigabyte-per-second (reading
from memory) and then the actual upload ran silently with no progress
shown. Now `Hex.HTTP` passes `{:stream, fun, offset}` through to
`Pool.Conn`, which calls `Mint.HTTP.stream_request_body/3` chunk by
chunk — the callback fires as bytes actually go out on the wire.
IPv4/IPv6 fallback:
`Hex.HTTP.retry` swaps `:inet`/`:inet6` in `connect_opts` on
`:nxdomain`/`:ehostunreach` to recover from hosts that resolve on only
one IP family. The pool was keyed on `{scheme, host, port}` and reused
the first request's `connect_opts` forever, so the swapped opts never
reached a new connect. Include the inet variant in the Host registry
key so the fallback retry actually gets its own pool with the opposite
inet flags.
Vendor script:
Add a comment block at the top of `scripts/vendor_mint.sh` listing the
upstream Mint PRs that must be present in any source tree used for
re-vendoring (#478 Elixir ~> 1.12 support, already applied; #479 1xx
informational handling, still open), with links to the PRs and to the
fork branches if re-vendoring before merge.
Exercises the full Mint pipeline end-to-end: TLS handshake, certificate verification, ALPN protocol negotiation, the connection pool, and response decoding. Both hosts currently serve HTTP/2, so these also cover the HTTP/2 statem path that bypass-based tests don't reach (bypass speaks HTTP/1 only). Six tests: GET /api/packages/phoenix on hex.pm; GET /names and GET /packages/phoenix on repo.hex.pm; ALPN-protocol assertions for both hosts (Host's stored protocol is `:http1` or `:http2`); and pool-reuse confirming a second request to the same host hits the same Host pid in the registry. Tagged `:network` so the suite can opt out with `mix test --exclude network` in offline environments, but the tag is not in the default exclude list so plain `mix test` runs them.
Proxy routing:
Added a bypass-free test that spins up a bare TCP listener acting as an
HTTP proxy, configures `:http_proxy` with credentials, and asserts the
request arrives with the absolute-URI request line and a
`proxy-authorization: Basic ...` header. Bypass (Cowboy) rejects
absolute-URI requests with 400, so a bypass-based test isn't possible —
the tiny TCP proxy accepts in a loop to handle both probe connections
the pool opens.
Related fix: `proxy_connect_opts` now passes the proxy host as a binary
rather than a charlist. Mint's `Core.Util.hostname/2` only accepts
binaries when deriving a hostname from the address, so a charlist proxy
address raised an ArgumentError before any bytes went out. Updated the
corresponding `proxy_config` assertion to match the new shape.
Pool coverage:
`test/hex/http/pool_test.exs` adds three tests for the unified pool:
* Different inet variants (`{:inet4, true, :inet6, false}` vs the
reverse) get separate Host registrations under distinct registry
keys — validates the fix that made IPv4↔IPv6 retry fallback
actually take effect.
* Killing a `Conn` process causes `Host` (trap_exit) to spawn a
replacement and the pool remains functional for subsequent
requests — exercises the supervision path.
* Saturating the HTTP/1 pool with more concurrent requests than
`@http1_size` (8) queues the excess callers and drains them as
in-flight requests finish.
Benchmarked `rm -rf ~/.hex/cache.ets ~/.hex/packages deps; mix deps.get` on a real project, 10 runs each, total time: httpc (main): 29.2s (baseline) Mint, HTTP/1+HTTP/2, 2 probes: 32.7s (+12%) Mint, HTTP/2, 1 probe: 42.3s (+45%) Mint, HTTP/2, 8 probes: 30.5s (+4%) Mint, HTTP/1, 2→8 pool: 27.8s (-5%, fastest) HTTP/2 consistently loses for hex's workload (many small tarball GETs). The multiplexing win doesn't offset Mint's per-stream HPACK/frame processing cost in pure Elixir. Fewer Conn processes also means fewer BEAM scheduler slots working in parallel on response parsing — HTTP/2 with 8 probe conns nearly matches HTTP/1 with 8 conns, which confirms the bottleneck is the single-Conn-process serialization of response events rather than anything on the wire. HTTP/1 with 8 conns beats httpc by ~5%. Matches the historical httpc behaviour (which was HTTP/1 only via `:inets`), so no semantic change for any caller. `Conn.do_connect` pins `protocols: [:http1]`. The HTTP/2 capacity logic is kept in place so a caller that overrides `:protocols` in `:connect_opts` still works; it's just not the default.
HTTP/2 defines a spec-mandated 64 KB initial connection-level receive window that cannot be changed via SETTINGS (only per-stream window is settable that way). For bulk downloads like hex's tarballs — multi-MB bodies across many parallel streams sharing one connection — this window fills in milliseconds and then every subsequent ~64 KB of data has to wait a full RTT for Mint's auto WINDOW_UPDATE to reach the server, capping throughput far below the TCP rate. Added `:connection_window_size` option to `Hex.Mint.HTTP2.initiate/5` that, when greater than the default 65_535, piggybacks a WINDOW_UPDATE frame on the client preface bumping the connection window up to the caller's target. `Conn.do_connect` now sets it (and the per-stream `initial_window_size`) to 8 MB so HTTP/2 doesn't stall mid-stream if a caller opts into HTTP/2 via `:connect_opts`. Benchmarked `rm -rf ~/.hex/cache.ets ~/.hex/packages deps; mix deps.get` 10 runs total against a real hexpm project: HTTP/2, default windows, 2 probes: 32.7s (+12% vs httpc) HTTP/2, stream window 8 MB only: 31.9s HTTP/2, both windows 8 MB: 29.2s (= httpc) HTTP/1, default: 27.8s (-5% vs httpc, fastest) Conn still pins `protocols: [:http1]` by default — HTTP/1 remains ~5% faster than HTTP/2 for hex's many-small-GETs workload because Mint's pure-Elixir HPACK and frame parsing costs more per request than HTTP/1 line parsing, and multiplexing doesn't recover that cost. But the patch + the configured window options mean HTTP/2 is now at parity with httpc rather than a regression, so callers who need HTTP/2 (e.g. org repos that only speak it) don't take a throughput hit. Marked with `HEX PATCH` in `lib/hex/mint/http2.ex` and documented in `scripts/vendor_mint.sh` alongside the other pending upstream items. TODO: upstream as a Mint PR.
Earlier commit defaulted to HTTP/1 based on measurements that showed a ~5% wall-time gap vs HTTP/1. Re-running the benchmark on a quieter network revealed that gap was within noise — 28.0s–30.5s across a handful of 10-run cycles, with no systematic winner. Comparing CPU use with `/usr/bin/time -lp` on a single `mix deps.get`: HTTP/1: real 3.11s user 1.65s sys 1.79s (CPU 3.44s) HTTP/2: real 2.62s user 1.58s sys 1.62s (CPU 3.20s) HTTP/2 actually uses slightly *less* CPU (fewer TLS handshakes) and is equivalent or better on wall time. The earlier hypothesis that Mint's pure-Elixir HPACK/frame parsing costs enough to make HTTP/2 slower was wrong — total CPU budget is dominated by TLS handshake, tarball unpack (zlib + crypto), and file I/O, not HTTP parsing. Flip `do_connect` back to `protocols: [:http1, :http2]` so ALPN negotiates. The 8 MB window tuning stays — it's what makes HTTP/2 viable (default 64 KB windows stall multi-MB tarball downloads).
Refactored the Mint HTTP/2 connection-window patch from a narrow
`:connection_window_size` connect option into a proper public API,
`Mint.HTTP2.set_window_size(conn, target, new_size)`, that supports
both `:connection` and `{:request, ref}` and can be called at any point
after connect. Tracks the receive window in a new `receive_window_size`
field (connection and stream); grow-only; validated to `1..2^31-1`.
This is the function shape that fills a longstanding, well-known gap in
Mint's public API — upstream issue #357 (2022, closed) asked for exactly
this, #432 (2024, still open) is a related enhancement. Ready to submit
upstream as a PR.
On the hex side:
* Re-vendor from the integration branch (ericmj/hex-vendor-integration)
which has PR #478 (Elixir 1.12), PR #479 (HTTP/1 1xx handling) and
the new set_window_size/3 commit all stacked.
* `Conn.do_connect` now calls `Hex.Mint.HTTP2.set_window_size(conn,
:connection, 8_000_000)` immediately after a successful HTTP/2 connect.
No-op on HTTP/1. TCP ordering guarantees the WINDOW_UPDATE reaches the
server before any request HEADERS, so there's no extra RTT.
* `:client_settings: [initial_window_size: 8_000_000]` still handles the
per-stream initial window via SETTINGS.
* Update `scripts/vendor_mint.sh` comment block to point at the
integration branch and list all three upstream Mint patches with
branch links.
Absorbs two new upstream Mint commits on top of the existing vendored
stack:
* `Raise default HTTP/2 receive windows` — bumps Mint's defaults from
the spec-mandated 64 KB to 4 MB per stream and 16 MB per connection.
At typical RTTs (10-150 ms) 64 KB caps throughput far below link
speed; 4/16 MB unlocks ~40 MB/s transcontinental and stream < conn
lets ~4 parallel streams run at full rate before the conn pool binds.
* `Batch HTTP/2 receive-window refills` — gates `WINDOW_UPDATE` on a
configurable threshold (`:receive_window_update_threshold`, default
160_000, ~10× the default max frame size) instead of refilling on
every DATA frame. Mitigates the amplification-DoS shape where a
malicious server sends many tiny DATA frames to force many
WINDOW_UPDATE responses.
On the hex side this means the explicit window tuning that the previous
re-vendor added to `Conn.do_connect` (setting `client_settings:
[initial_window_size: 8_000_000]` and calling `set_window_size(conn,
:connection, 8_000_000)`) is now redundant — Mint's 4/16 MB defaults
already cover hex's bulk-tarball workload. Drop the tuning block and the
`maybe_bump_connection_window/1` helper; `do_connect` now just sets
`protocols: [:http1, :http2]` and lets Mint's defaults handle the rest.
Also:
* Exclude the vendored `lib/hex/mint/**` tree from `.formatter.exs` so
`mix format --check-formatted` doesn't fight upstream formatting
every re-vendor.
* Format drift in `lib/hex/http.ex` and `lib/hex/http/pool.ex` that the
vendored formatter exclusion surfaced.
* Update `scripts/vendor_mint.sh` comment block to list the new
larger-default-windows branch alongside the other pending upstream
items.
The initial rebase resolution for `request_to_file/6` (from hex_core
0.15.0) just called the in-memory `Pool.request/5` and then did
`File.write/2` on the full binary. For tarballs that can be tens of MBs
this pays for the body twice: once in the `Conn` accumulator and once on
disk.
Add a real streaming path through the pool:
* `Pool.request_to_file/6` and `Host.request_to_file/7` — same dispatch
as `request/5` but carry the target filename.
* `Conn` opens the file in `[:write, :raw, :binary]` mode before
issuing the Mint request and writes each `:data` chunk straight to
disk. On `:done` the file is closed and the caller gets
`{:ok, status, headers, nil}`.
* On `{:status, ref, _}` mid-request (1xx → final, or a follow-up
response on the same ref) the sink is rewound + truncated so a 1xx
body never bleeds into the final payload.
* On transport `:error` or a write error the partial file is removed
so callers never see a half-written payload.
Redirects keep working as-is: each `do_request` opens the file fresh
with `[:write]` mode which truncates, so a 3xx response body is
overwritten by the follow.
Added two pool tests: the 5 MB streaming-without-buffering test and a
redirect-truncation test that asserts a `302 → 200` chain leaves only
the final body on disk.
All four Mint changes Hex depended on are released upstream (elixir-mint/mint#478, #479, #480 and #481), so vendor from Mint main (fb850d3, v1.11.0) instead of the integration branch and drop the list of pending patches from scripts/vendor_mint.sh. Mint.Application no longer exists upstream, so the skip list for it is gone too. Mint v1.11.0 reads `:proxy_headers` from the top-level connect options and only uses the `:proxy` tuple's options for the connection to the proxy (elixir-mint/mint#494), so Hex.HTTP now passes the proxy-authorization header there.
Conn sent the whole request body right after the headers, in a loop that never processed incoming frames. That broke two things: * Requests with `expect: 100-continue` (package and docs publishing) uploaded the body before the server could reject them, which undoes #1219: the tarball went out on the request that came back 401 asking for an OTP code. * Over HTTP/2 a body larger than the server's send window failed with `{:exceeds_window_size, ...}`, because WINDOW_UPDATE frames were only processed after the loop returned. hex.pm negotiates HTTP/2 and advertises 1 MiB windows, so publishing anything bigger failed. Bodies are now sent in chunks capped by `request_body_window/2` and resumed from handle_info/2 once the server has opened the window. With `expect: 100-continue` the body waits for a 100 status. If the final response arrives first the body is never sent, and an HTTP/1 connection, which is still mid-request at that point, is closed and reconnected. Binary bodies take the same path with an explicit content-length.
Mint v1.11.0 and hpax v1.1.0 require Elixir 1.15 and use the pin operator in binary size specifiers (`size(^var)`), which fails to compile on Elixir 1.12-1.14 with "cannot use ^var outside of match clauses". Hex still supports Elixir ~> 1.12, so vendor_mint.sh now rewrites them to `size(var)`. Elixir 1.20 prints a deprecation warning for each of the 6 sites.
The Host opened two connections when it started and eight once the
first one negotiated HTTP/1. A Conn whose connect failed or whose
connection closed reconnected itself with a backoff of 1 to 30
seconds, and a request dispatched to a Conn that had just stopped
taking requests got {:error, :disconnected}. That gave three problems:
* When nothing listened on the port, requests waited in the Host
until their timeout, 15 s by default, instead of failing with the
connect error. The test suite spent 45 s of 80 s in three tests
against unreachable hosts.
* A server that closes the connection after each response, such as
an HTTP/1.0 server, made the Host dispatch requests to Conns that
had just closed, since the Conn casts req_done before it casts that
it stopped taking requests. 16 to 19 of 40 concurrent requests
failed with {:error, :disconnected} in five runs of the new test,
and POST requests aren't retried.
* HTTP/1 was limited to eight connections, one request each, so
requests beyond eight waited in the Host.
A Conn now holds a single connection. When connecting fails or the
connection closes it tells the Host, which stops it. The Host opens a
connection for each waiting request on HTTP/1, one at a time on
HTTP/2 when every connection is at max_concurrent_streams, and at most
two while the protocol is unknown. When a connect fails and no other
connection is open or connecting, the waiting requests get the connect
error, which Hex.HTTP retries. A Conn that gets a request after it
stopped taking requests hands it back to the Host to be dispatched
again.
proxy_connect_opts/1 is only called with a %URI{}, so its catch-all
clause never matched, and maybe_proxy_ignored/1 always returned [].
Mint reports transport errors as Hex.Mint.TransportError, so
:socket_closed_remotely, an httpc error, never reaches retryable?/1.
ericmj
force-pushed
the
claude/add-hex-core-adapter-id9BK
branch
from
October 6, 2026 11:02
ec9f024 to
b3d7b10
Compare
scripts/vendor_mint.sh now:
* Adds Mint's and HPAX's copyright lines, taken from their READMEs,
and a line saying the file was modified to the header of every
vendored file, as the Apache License 2.0 asks for modified files.
The README lists the vendored code.
* Adds @moduledoc false where it turns @moduledoc text into
`_ = """`. Hex.Mint.HTTP, HTTP1, HTTP2, HPAX, HTTPError,
TransportError and Types had no moduledoc at all, so ExDoc would
list them in Hex's documentation.
* Rewrites `size(^var)` to `size(Hex.Mint.Compat.pin(var))`, a macro
that pins the variable on Elixir 1.15 and later and leaves it
unpinned on Elixir 1.12 to 1.14, which don't accept the pin there.
Elixir 1.20 warned about the six unpinned variables. The macro
compiles without warnings and gives the same results on Elixir
1.12.3, 1.14.5 and 1.20.4.
* Only renames `Mint.` followed by a module name or `{`, so prose
such as "provided by Mint." stays as is, and refuses to run on a
Mint checkout with uncommitted changes.
The vendored files are regenerated from Mint v1.11.0 (fb850d3) and
HPAX 1.1.0. Apart from the headers and the moduledocs, the six size
specifiers and the require of Hex.Mint.Compat are the only changes.
mix.exs silences the undefined-function warnings for
CAStore.file_path/0, :public_key.cacerts_get/0 (OTP 24) and
:ssl.cipher_suites/1. Vendored Mint only calls them when no CA
certificates or ciphers are given, and Hex always gives both.
Hex passes its own cipher list, so Mint doesn't remove the suites that RFC 9113 Appendix A prohibits for HTTP/2, and the list started with AES128-GCM-SHA256, which is one of them. A server that picks the client's preferred suite could negotiate HTTP/2 with it, and HTTP/2 servers may close such connections with INADEQUATE_SECURITY. The ECDHE suites with AES-GCM or ChaCha20-Poly1305 now come first. The other suites stay, after them, for servers that don't support those.
* Credentials in a URL, such as a repository configured as
https://user:pass@repo.example.com, are sent as basic auth again.
httpc did this and the pool ignored them. They aren't sent to
redirect targets.
* HTTPS requests go through http_proxy when https_proxy isn't set,
as they did with httpc.
* no_proxy entries `*`, `*.example.com` and IP address prefixes
such as `10.` match again, and entries are compared without case.
* A proxy URL with a username and no password sends `user:` in
proxy-authorization, as httpc did, instead of `user`.
* The proxy connection uses the request's address family, so the
IPv4 to IPv6 fallback also applies to proxies. Connecting, the TLS
handshake and the proxy tunnel are limited by HEX_HTTP_TIMEOUT
like the request, as httpc's connect timeout was, instead of
Mint's 30 s default.
* After a request falls back to the other address family, later
requests start with it, as they did when httpc switched the
profile's ipfamily.
* Requests the server didn't process are retried for every method:
connection refused, unreachable host or network, unknown host,
and HTTP/2 streams rejected by GOAWAY or REFUSED_STREAM. Other
errors are still only retried for GET requests.
* A repeated response header keeps its last value, as it did with
httpc. Joining the values broke the parsing of x-hex-message.
* When several connects failed at once, each stopped Conn was
replaced when its exit arrived, so the waiting requests waited
for their timeout instead of failing with the connect error, which
Hex.HTTP retries. A failed connect now fails the waiting requests
when no connection is ready, and stopped Conns aren't replaced.
* A request wasn't cancelled when its caller gave up after the
timeout. A queued request was still sent later, and
request_to_file recreated the file Hex.HTTP had deleted. The Host
and the Conns monitor callers and drop or cancel their requests.
* HTTP/2 connections were assumed to take Mint's default of 100
concurrent streams because Mint returns from connect before the
server's SETTINGS frame arrives, so requests beyond a lower limit
failed with :too_many_concurrent_requests. A Conn now reports
ready after the SETTINGS frame and reports later changes to
max_concurrent_streams. Requests above a lowered limit are
dispatched again.
* A request body that couldn't be sent after GOAWAY failed every
request on the connection. Only that request fails now.
* A failed write to the response file didn't reset the HTTP/2 stream
or close the HTTP/1 connection.
* Responses for refs the Conn didn't know, such as pushed streams or
trailers after a failed write, added nil entries to its requests,
which crashed it on the next connection error. Server push is
disabled and such responses are ignored.
* Requests a Conn had when it crashed or was killed waited for their
timeout. The Host tracks the requests it gave each Conn and fails
them when the Conn exits.
* A Conn replied before it told the Host the request was done, so a
caller's next request could open an extra HTTP/1 connection.
* The client never closed idle connections. They're closed after
120 s without requests, httpc's keep_alive_timeout in Hex.
* Host pools were keyed by scheme, host, port and address family, so
a request with another proxy used the first request's connect
options. The connect options other than the transport options are
part of the key now.
* A server that sends GOAWAY with its SETTINGS frame counts as a
failed connect, so the Host doesn't reconnect in a loop.
HexTest.H2Server is a scripted HTTP/2 server for the SETTINGS and
GOAWAY tests.
The total request timeout in Hex.HTTP.timeout/2 returns a bare
{:error, :timeout}, which retryable?/2 didn't retry, so one stalled
request failed the whole mix deps.get. GETs that time out are retried
like on main since #1305.
Co-authored-by: Matthew Wood <964851+woodm1979@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces
:httpcwith a vendored copy of Mint v1.11.0 and HPAX v1.1.0 behind Hex'shex_coreHTTP adapter. Connections negotiate HTTP/2 with ALPN and fall back to HTTP/1.Changes
scripts/vendor_mint.shcopies Mint and HPAX intolib/hex/mint/asHex.Mint.*. It removes^from binary size specifiers because Elixir 1.12 to 1.14 don't allow it there, so Elixir 1.20 warns about the unpinned variables in six places in the vendored code. Compiling also warns thatCAStore.file_path/0and:ssl.cipher_suites/1are undefined. Mint only calls the first when no CA certificates are given and:public_key.cacerts_get/0fails, and the second on ssl older than 8.2.4.Hex.HTTP.Poolruns aHostper scheme, host, port and IPv4/IPv6 family. AHostopens connections, each owned by aConnprocess, when a request has to wait: one per waiting request on HTTP/1, and on HTTP/2 another one only when every connection hasmax_concurrent_streamsrequests in flight. A failed connect fails the waiting requests with the connect error, whichHex.HTTPretries, switching between IPv4 and IPv6 for unreachable-network errors. A connection that closes or receives GOAWAY finishes its requests and is replaced when requests need it.stream_request_body/3within the HTTP/2 flow-control window. WithExpect: 100-continuethe body is sent after100 Continue, soHex.HTTPno longer addsconnection: closeto those requests as it did for httpc.request_to_file/6writes the body to the file as it arrives. A 1xx response starts a new response, so headers of103 Early Hintsdon't end up on the final response.http_proxyandhttps_proxy, with credentials sent asproxy-authorization.Measurements
mix deps.getof the 100 Hex packages in hexpm'smix.lock(130 registry requests and 101 tarballs, 11.3 MB) on macOS 27 with Elixir 1.20.4 and OTP 29, about 11 ms from repo.hex.pm, againstmainat011d2a8. Each value is the median of 15 interleaved runs between 10:58 and 11:01 UTC on 2026-10-06. Cold runs start with an empty Hex cache and nodepsdirectory, warm runs keep the Hex cache, anddeps/was identical in every run. HTTP/1 was forced with a benchmark-only change to the:protocolsconnect option.main,:httpcMint matches
:httpcon time, and over HTTP/2 the peak RSS is 114 to 134 MB lower.mainfetches 32 registry files at a time since #1257, and its peak RSS follows that limit: 202 to 208 MB with 8 registry fetches at a time and 306 to 313 MB with 32, in 6 runs each. Mint over HTTP/1, which opens a connection for each concurrent request, uses about as much as:httpc, while HTTP/2 serves the same requests over one or two connections. That points at the cost of the connections, but I haven't measured where the memory goes.