Repository navigation
feat(configuration): define per-package default timeout constants (#1793) - #1794
Conversation
…rrust#1793) Remove `DEFAULT_TIMEOUT` from `torrust-tracker-configuration` and define context-specific local constants in each consumer package: - `packages/tracker-client`: `DEFAULT_UDP_TIMEOUT` (UDP I/O) - `packages/axum-http-tracker-server`: `DEFAULT_REQUEST_TIMEOUT` (HTTP request processing) - `packages/axum-rest-tracker-api-server`: `DEFAULT_REQUEST_TIMEOUT` (REST API request processing) - `packages/udp-tracker-server`: `DEFAULT_SERVER_LIFECYCLE_TIMEOUT` (server start/stop), `DEFAULT_UDP_TIMEOUT` (UDP test client) - `console/tracker-client`: `DEFAULT_NETWORK_TIMEOUT` (all network operations) Drop `torrust-tracker-configuration` from `Cargo.toml` of `packages/tracker-client` and `console/tracker-client` as the dependency was only needed for this constant. Closes torrust#1793
There was a problem hiding this comment.
Pull request overview
This PR removes the workspace-wide DEFAULT_TIMEOUT constant from packages/configuration and replaces it with context-specific, per-package default timeout constants, reducing coupling on the configuration crate and clarifying intent at call sites.
Changes:
- Introduce package-local timeout defaults (e.g.,
DEFAULT_UDP_TIMEOUT,DEFAULT_REQUEST_TIMEOUT,DEFAULT_SERVER_LIFECYCLE_TIMEOUT,DEFAULT_NETWORK_TIMEOUT) and update call sites. - Drop
torrust-tracker-configurationdependencies where they existed solely to import the old timeout constant. - Regenerate/update the workspace coupling report and related EPIC/spec documentation.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/udp-tracker-server/tests/server/contract.rs | Replaces shared timeout import with a local DEFAULT_UDP_TIMEOUT for contract tests. |
| packages/udp-tracker-server/src/environment.rs | Replaces shared timeout import with DEFAULT_SERVER_LIFECYCLE_TIMEOUT for env start/stop timeouts. |
| packages/tracker-client/src/udp/client.rs | Introduces DEFAULT_UDP_TIMEOUT for UDP client checks. |
| packages/tracker-client/Cargo.toml | Removes configuration dependency now that timeout is local. |
| packages/configuration/src/lib.rs | Deletes DEFAULT_TIMEOUT and the now-unused Duration import. |
| packages/axum-rest-tracker-api-server/src/routes.rs | Introduces DEFAULT_REQUEST_TIMEOUT for TimeoutLayer in API routes. |
| packages/axum-http-tracker-server/src/v1/routes.rs | Introduces DEFAULT_REQUEST_TIMEOUT for TimeoutLayer in HTTP tracker routes. |
| console/tracker-client/src/lib.rs | Adds crate-level DEFAULT_NETWORK_TIMEOUT used by CLI clients. |
| console/tracker-client/src/console/clients/unified/udp.rs | Switches unified UDP client to DEFAULT_NETWORK_TIMEOUT. |
| console/tracker-client/src/console/clients/unified/http.rs | Switches unified HTTP client to DEFAULT_NETWORK_TIMEOUT. |
| console/tracker-client/src/console/clients/unified/check.rs | Switches unified check runner to DEFAULT_NETWORK_TIMEOUT. |
| console/tracker-client/src/console/clients/udp/app.rs | Switches UDP app client to DEFAULT_NETWORK_TIMEOUT. |
| console/tracker-client/src/console/clients/http/app.rs | Switches HTTP app client to DEFAULT_NETWORK_TIMEOUT. |
| console/tracker-client/src/console/clients/checker/service.rs | Switches checker service to DEFAULT_NETWORK_TIMEOUT. |
| console/tracker-client/Cargo.toml | Removes configuration dependency now that timeout is local. |
| docs/issues/open/1793-1669-03-define-per-package-default-timeout-constants.md | Adds the open issue spec documenting the approach and verification. |
| docs/issues/open/1669-overhaul-packages/workspace-coupling-report.md | Updates the generated coupling report content. |
| docs/issues/open/1669-overhaul-packages/EPIC.md | Updates SI-03 wording/links to reflect the new approach. |
| docs/issues/drafts/1669-03-move-default-timeout-from-configuration-to-clock.md | Removes the superseded draft spec. |
| Cargo.lock | Removes configuration from dependency resolution for updated crates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| --- | ||
| doc-type: issue | ||
| issue-type: task | ||
| status: open |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1794 +/- ##
========================================
Coverage 77.72% 77.73%
========================================
Files 378 378
Lines 28599 28602 +3
Branches 28599 28602 +3
========================================
+ Hits 22229 22233 +4
- Misses 6060 6063 +3
+ Partials 310 306 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Address Copilot review on PR torrust#1794: - Move `DEFAULT_REQUEST_TIMEOUT` below the full `use` block in `packages/axum-rest-tracker-api-server/src/routes.rs` - Remove stale `torrust-tracker-configuration → torrust-tracker-clock` entry from workspace-coupling-report.md; the dependency no longer exists after SI-03 removed `DEFAULT_TIMEOUT` from configuration
Remove from pre-push the steps already covered by pre-commit (cargo machete, linter all, cargo test --doc --workspace) and the E2E tests runner. E2E tests run only in CI. The hook now runs only the nightly toolchain checks and the full stable test suite, cutting runtime from ~376s to ~23s. Update the run-pre-push-checks, run-pre-commit-checks, and AGENTS.md gate ownership descriptions accordingly. Add a new push-changes skill documenting the push workflow and the SSH idle-timeout problem with Fix 1 workaround and warning about automated environments.
Add contrib/dev-tools/git/check-git-hooks.sh to verify that all project Git hooks from .githooks/ are installed. The script iterates over every hook, reports each as installed or NOT installed, and exits 1 if any are missing. Replace the ad-hoc inline one-liner used in skills and agent instructions with a call to the new script for consistency.
|
ACK 3f5e526 |
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of the change from #1794 as it stands at e170b96 on the default branch.
What still runs: the per-package 5-second timeout constants (DEFAULT_UDP_TIMEOUT in packages/tracker-client/src/udp/client.rs:17 and packages/udp-server/tests/server/contract.rs:16, DEFAULT_REQUEST_TIMEOUT in packages/axum-http-server/src/v1/routes.rs:29 and packages/axum-rest-api-server/src/routes.rs:32, DEFAULT_NETWORK_TIMEOUT in console/tracker-client/src/lib.rs:5 and its callers in console/tracker-client/src/console/clients/unified/), the check-git-hooks.sh script (extended by 474f514 with a sync check), and the shortened pre-push list in contrib/dev-tools/git/hooks/pre-push.sh. The UDP test environment's lifecycle constant became DEFAULT_SERVER_START_TIMEOUT in 8e2b59c, which also removed the stop timeout. The pull request description lists only the timeout constants; the new hook script and the removal of four pre-push checks (machete, linters, doc tests, E2E) are not mentioned there.
[Minor] contrib/dev-tools/git/hooks/pre-push.sh:4-6 and :45-54: #1794 removed cargo +stable machete from the pre-push hook on the premise that pre-commit checks always run before each commit, a premise the run-pre-push-checks skill repeats. It does not hold for a commit made with git commit --no-verify, or for a commit whose content changed while resolving a git rebase conflict, because rebase does not run the pre-commit hook. For linters and doc tests CI closes that gap (.github/workflows/testing.yaml:97 and :101), but no workflow runs cargo machete, neither at the base of #1794 nor at e170b96. Sequence: a commit made with --no-verify removes the last use of a dependency; the push runs fmt, check, doc, package and tests, which all pass; CI passes; the unused dependency lands, against AGENTS.md:138. Before #1794 the pre-push machete check failed that push. The gap is recorded in docs/issues/open/2003-overhaul-guardrails-and-automation/initial-inventory.md:44 and :53 and is still open. Smallest fix: restore cargo machete --with-metadata in the pre-push list, or run it as a CI job, which would also cover pushes made without the hook. Either way, reword the comment and the skill text so they no longer say that every pushed commit passed pre-commit.
[Nit] contrib/dev-tools/git/check-git-hooks.sh:26-54 reports one combined status for every hook in .githooks/, but its callers ask about a single hook: .github/agents/committer.agent.md:57-65 asks whether the pre-commit hook is installed and branches only on installed or not installed. Suppose the pre-commit dispatcher is current and no pre-push hook is installed. The script prints installed: pre-commit, NOT installed: pre-push and the FAILURE summary, then exits 1. A caller that reads the exit status or the summary line runs pre-commit.sh by hand, and git commit then runs it again: the double run the check is meant to prevent. The OUT OF SYNC state has no branch in those instructions, although a stale but executable hook still runs on commit. Smallest fix: accept optional hook names (check-git-hooks.sh pre-commit), check only those, and have each caller pass the hook it asks about.
[Nit] packages/axum-rest-api-server/src/routes.rs:32: DEFAULT_REQUEST_TIMEOUT sits between the external imports and the use super:: and use crate:: imports at lines 36-39, against AGENTS.md:64 (all imports at the top of the file). Commit 1b81fbd describes moving it below the full use block, but it only moved it below the external group. Its counterpart at packages/axum-http-server/src/v1/routes.rs:29 follows all imports. Smallest fix: move lines 36-39 above line 32.
Checked and found sound: every replacement constant keeps the previous 5-second value, so the timeouts applied by the HTTP tracker, the REST API, the UDP client, the console checker and the UDP contract tests are unchanged. The torrust-tracker-configuration dependencies dropped from tracker-client and console tracker-client had no other use. At e170b96, check-git-hooks.sh only reads, resolves the hooks directory through git rev-parse --git-path hooks exactly as install-git-hooks.sh does, and detects stale copies; the version at the head of #1794 accepted any executable file, which 474f514 fixed. The remaining pre-push checks and the UDP test environment's start timeout raise no correctness or security concern.
Summary
Remove the shared
DEFAULT_TIMEOUTconstant fromtorrust-tracker-configurationand replace it with per-package timeout constants, each named to reflect the specific operation context of its package.Changes
packages/tracker-client: addedDEFAULT_UDP_TIMEOUT; droppedtorrust-tracker-configurationdependencypackages/axum-http-tracker-server: addedDEFAULT_REQUEST_TIMEOUTin routes modulepackages/axum-rest-tracker-api-server: addedDEFAULT_REQUEST_TIMEOUTin routes module (discovered consumer, not in original spec)packages/udp-tracker-server: addedDEFAULT_SERVER_LIFECYCLE_TIMEOUT(environment.rs) andDEFAULT_UDP_TIMEOUT(contract tests)console/tracker-client: addedDEFAULT_NETWORK_TIMEOUTat crate root; updated all 6 consumer files; droppedtorrust-tracker-configurationdependencypackages/configuration: removedDEFAULT_TIMEOUTconstant and the now-unuseduse std::time::DurationimportMotivation
A single generic timeout shared across the workspace is too coarse-grained. Each package performs a different kind of network operation and should own its timeout default with a name that reflects its specific context. Sharing a constant from the configuration crate creates unnecessary coupling — packages that have no other reason to depend on
torrust-tracker-configurationwere forced to do so solely for a timeout value.Related
DEFAULT_TIMEOUTfromtorrust-tracker-configuration#1793