Repository navigation
fix(axum-server): [#2776] adopt axum-server 0.9 timeouts and close idle-connection gaps #2813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
josecelano
merged 14 commits into
torrust:develop
from
josecelano-bot:2776-axum-server-0-9-timeouts
Nov 11, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5eb9293
chore(deps): [#2776] require axum-server 0.9
josecelano-bot 7d4645b
test(axum-server): [#2776] add red idle-connection regression tests
josecelano-bot e7a6ff7
fix(axum-server): [#2776] close idle connections with first_request_t…
josecelano-bot 167841c
refactor(axum-server): [#2776] remove the TimeoutAcceptor wrapper
josecelano-bot 024eb56
docs(issues): [#2776] record evidence, decisions and EPIC #2411 case …
josecelano-bot 8dfb1b3
fix(axum-server): [#2776] address PR review round 1
josecelano-bot 9d5e6eb
docs(pr-reviews): [#2776] record the PR 2813 review round 1 audit and…
josecelano-bot b10f168
docs(issues): [#2776] record the maintainer ruling on AC4 and tick AC…
josecelano-bot bfb1074
docs(axum-server): [#2776] describe what the package provides after t…
josecelano-bot 29beae7
Merge remote-tracking branch 'torrust/develop' into 2776-axum-server-…
josecelano-bot deda2c2
docs(axum-server): [#2776] add the ADR to close idle connections with…
josecelano-bot 954ef83
test(axum-servers): [#2776] add silent-connection tests and a clippy …
josecelano-bot 4793460
fix(axum-server): [#2776] address PR review round 2
josecelano-bot 6b38430
docs(pr-reviews): [#2776] record the PR 2813 review round 2 audit and…
josecelano-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Every Axum listener must be built through `torrust_tracker_axum_server::custom_axum_server`, which | ||
| # applies the connection timeouts (the first-request timeout closes silent connections). A listener | ||
| # built with these `axum-server` constructors directly keeps idle connections open forever, which | ||
| # lets a flood of silent connections exhaust the process's file descriptors (issue #2776, EPIC | ||
| # #2411 case A2). See `packages/axum-server/README.md`. | ||
| # | ||
| # Only the two constructors in `custom_axum_server.rs` call them, each with a documented `allow`. | ||
| # The decision is recorded in `docs/adrs/` (see the ADR on closing idle connections). | ||
| disallowed-methods = [ | ||
| { path = "axum_server::from_tcp", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum_server::tls_rustls::from_tcp_rustls", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum_server::bind", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum_server::tls_rustls::bind_rustls", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum_server::Server::bind", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum_server::Server::from_listener", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum_server::from_unix", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum_server::tls_rustls::from_unix_rustls", reason = "build listeners with torrust_tracker_axum_server::custom_axum_server so they get the connection timeouts (#2776)" }, | ||
| { path = "axum::serve", reason = "axum::serve has none of the connection timeouts; build listeners with torrust_tracker_axum_server::custom_axum_server (#2776)" }, | ||
| ] | ||
84 changes: 84 additions & 0 deletions
84
docs/adrs/20261111095222_close_idle_connections_without_a_408_response.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| --- | ||
| semantic-links: | ||
| skill-links: | ||
| - create-adr | ||
| related-artifacts: | ||
| - packages/axum-server/src/custom_axum_server.rs | ||
| - clippy.toml | ||
| - docs/adrs/20260830124000_place_adrs_by_decision_scope.md | ||
| - docs/issues/open/2776-2411-axum-server-0-9-timeouts/ISSUE.md | ||
| - .github/skills/dev/planning/create-adr/SKILL.md | ||
| --- | ||
|
|
||
| <!-- skill-link: create-adr --> | ||
|
|
||
| # Close idle connections without a 408 response | ||
|
|
||
| ## Scope | ||
|
|
||
| Repository-level. The decision is about protocol behaviour: whether the HTTP tracker, the REST API | ||
| and the health check API answer `408 Request Timeout` before closing an idle connection. The | ||
| listener constructors it describes live in `packages/axum-server`, but three server packages depend | ||
| on them, and the root `clippy.toml` that enforces their use binds every crate in the workspace. The | ||
| placement ADR (`20260830124000_place_adrs_by_decision_scope.md`) requires root placement for | ||
| protocol behaviour and shared configuration, even when one package implements it. | ||
|
|
||
| ## Description | ||
|
|
||
| A connection that is opened and never sends a request holds a Tokio task and a file descriptor for | ||
| as long as the client keeps it open. Issue #2776 made every Axum listener (plaintext and TLS, HTTP | ||
| tracker, REST API and health check API) close such connections with `axum-server` 0.9's | ||
| `Server::first_request_timeout`, 5 s by default. | ||
|
|
||
| When that timeout fires, `axum-server` returns from the connection task and drops the socket. The | ||
| client sees a plain close and no HTTP response. Some frameworks answer `408 Request Timeout` first | ||
| (Actix Web does, as the reproduction repository `josecelano/axum-server-timeout` shows). The | ||
| question is whether the tracker should do the same. | ||
|
|
||
| ## Agreement | ||
|
|
||
| The tracker closes the connection silently and does not send `408 Request Timeout` for a | ||
| connection that has not sent a complete first request, an idle keep-alive connection, or a TLS | ||
| handshake that does not complete. | ||
|
|
||
| Reasons: | ||
|
|
||
| - A connection that sent nothing has no pending request to answer, so a bare close is valid HTTP | ||
| (RFC 9110 allows a server to send `408` but does not require it). | ||
| - It is the cheapest response under abuse: no write, no response buffer, and no bytes sent to a | ||
| client that already proved it will not send a request. | ||
| - It needs no custom code. A `408` would need a wrapper around the connection for plaintext, TLS | ||
| and HTTP/2, like the `TimeoutAcceptor` removed in #2776, or a new upstream feature. | ||
| - The tracker's clients are BitTorrent clients that make short announce and scrape requests. A | ||
| silent connection is almost certainly a scanner or an abuse attempt, not a client that needs an | ||
| explanation. | ||
|
|
||
| A request that has arrived and whose handler is too slow still gets `408`, from the per-request | ||
| `TimeoutLayer` of the HTTP tracker and the REST API. That is a different timeout. | ||
|
|
||
| ### Alternatives Considered | ||
|
|
||
| - **Send `408` then close.** Rejected: more server work in the situation that should be cheapest, | ||
| custom code for each transport, and the client's next write still fails with a broken pipe, as in | ||
| the Actix Web reproduction. | ||
|
|
||
| ### Consequences | ||
|
|
||
| - Positive: no extra code to maintain; no response traffic for idle connections. | ||
| - Negative: clients and proxies see a reset or close instead of a `408`, and a reverse proxy may log | ||
| an upstream close. This is a known limitation. | ||
| - A client that answers the HTTP/2 keep-alive pings is not time-bounded by these timeouts; bounding it is the connection-limit work of EPIC #2411 case A1. | ||
| - Revisit this decision if real users report confusing logs behind a proxy. The preferred route is | ||
| an optional `408` in `axum-server` upstream, not custom tracker code. | ||
|
|
||
| ## Date | ||
|
|
||
| 2026-11-11 | ||
|
|
||
| ## References | ||
|
|
||
| - Issue [#2776](https://github.com/torrust/torrust-tracker/issues/2776) and its spec, | ||
| `docs/issues/open/2776-2411-axum-server-0-9-timeouts/ISSUE.md` | ||
| - `axum-server` 0.9.0, `Server::first_request_timeout` | ||
| - Reproduction repository: <https://github.com/josecelano/axum-server-timeout> | ||
| - RFC 9110, section 15.5.9 (`408 Request Timeout`) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion][F29] The list covers only the
axum-serverconstructors.axum::serve(axum 0.8.9 is in the lockfile) serves a router with none of these timeouts and is not forbidden; adding it closes the other route to an untimed listener. It is also worth checking against theaxum-server0.9 source that every listed path resolves and that no public constructor is missing, such as an associatedServer::from_tcpif 0.9 still has one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid. Fixed in
fix(axum-server): [#2776] address PR review round 2:axum::serveis forbidden, as areaxum_server::from_unixandtls_rustls::from_unix_rustls. I checked the 0.9.2 source: the public constructors arebind,from_tcp,from_unix,Server::bind,Server::from_listener,bind_rustls,from_tcp_rustlsandfrom_unix_rustls, and clippy accepts every path in the config.