Expand description
Shared reqwest::Client factory with project-wide timeouts.
Every HTTP call in pakx ultimately funnels through reqwest::Client.
Constructing one via Client::new() is convenient but leaves both
the request timeout and the connect timeout at reqwest’s default of
none — so a half-open TCP connection to a slow / blackholed
registry will hang the CLI indefinitely. The user can’t even
Ctrl+C out of the install loop cleanly because the futures are
parked on the network, not on a tokio timer.
This module centralises client construction so:
request_timeoutdefaults to 60s — long enough for an ordinary registry round-trip (federated search + metadata fetch) but short enough that a hung CI doesn’t sit for 30 minutes before the job scheduler kills it.connect_timeoutdefaults to 15s — fail fast on DNS / TCP issues instead of letting the request-timeout absorb the connect cost.- Long-running uploads (
pakx publish, in particular the tarball PUT) can opt into a longer request timeout viahttp_client_with_timeout.
All other call sites that previously used reqwest::Client::new()
must route through http_client so the timeout discipline is
uniform across install, publish, search, outdated, audit,
add, info, upgrade, and the registry sources. Auditing for
drift is then a single grep Client::new across the workspace.
Constants§
- DEFAULT_
CONNECT_ TIMEOUT - Default TCP/TLS connect timeout. Separate from the request timeout so DNS / unreachable-host errors surface in seconds rather than being absorbed into the full 60s request budget.
- DEFAULT_
REQUEST_ TIMEOUT - Default request-level timeout applied to every client built via
http_client. - UPLOAD_
REQUEST_ TIMEOUT - Request timeout for tarball uploads (
pakx publishPUT). The default 60s is too aggressive for a 50 MiB upload over a slow residential uplink; 5 minutes matches the registry’s own server- side limit.
Functions§
- http_
client - Build a
reqwest::Clientwith the project-wide default timeouts. - http_
client_ with_ timeout - Build a
reqwest::Clientwith a caller-supplied request timeout and the project-wide default connect timeout.