Skip to content

Stop the HTTP test environment's tasks when it is dropped without stop() #2471

Closed

Description

@josecelano

Parent EPIC: #1488. A gap that predates SI-16 (#2412, PR #2439): the HTTP test environment never stopped its server when dropped without stop(). An earlier version of this issue called it a regression from SI-16; PR #2544 review finding F5 showed that was wrong.

Goal

Dropping a running HTTP test environment (axum-http-server's testing::environment) without calling stop() stops its HTTP server and statistics event listener, as dropping the UDP test environment does, so the HTTP binding is released.

Bug

The running state holds a plain CancellationToken. Dropping a token does not cancel it, and dropping the task handles detaches the tasks, so the HTTP server keeps running and keeps its binding until the Tokio runtime shuts down. Reproduced on develop at 24bf4746a: after dropping a started environment, binding its address every 10 ms for 10 s never succeeded.

Before PR #2439, the running state held the legacy halt sender. Dropping it made torrust-server-lib's shutdown_signal panic inside the spawned shutdown task, before the task stopped the server, so the server kept serving; running the same drop test on the tree before SI-16 shows the binding still taken after 10 s. The UDP environment stops on drop because its legacy launcher treats a closed halt channel as a stop, and PR #2459 (finding F1) gave it a DropGuard. This issue aligns HTTP with UDP.

Impact: test-only and low; each test runtime stops the leaked tasks when the test ends.

Acceptance criteria

  • AC1: Dropping a running HTTP test environment without stop() releases its HTTP binding within the test deadline.
  • AC2: stop() keeps its behavior: it cancels once, joins every owned task, and reports failures as today; all existing environment tests pass.
  • AC3: The regression test is proven red before the fix and green after.
  • linter all exits with code 0
  • Relevant tests pass
  • Manual verification scenarios are executed and documented in issue-local manual-verification-evidence.md
  • Acceptance criteria are re-reviewed after implementation and reflect actual behavior

Specification: docs/issues/open/<number>-1488-fix-http-environment-drop-path/ISSUE.md (added by the spec-only PR).

Activity

  1. self-assigned this
    on Oct 7, 2026
  2. added
    Bug
    on Oct 7, 2026
  3. 17 remaining items

  4. added 7 commits that reference this issue on Oct 15, 2026
  5. added a commit that references this issue on Oct 16, 2026
  6. added 6 commits that reference this issue on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions