Skip to content

fix(server): bound the HTTP graceful shutdown with a deadline - #439

Merged
plusky merged 1 commit into
plusky:mainfrom
scarabeusiv:fix/shutdown-deadline
Nov 20, 2026
Merged

plusky merged 1 commit into
plusky:mainfrom
scarabeusiv:fix/shutdown-deadline

Conversation

@scarabeusiv

Copy link
Copy Markdown
Contributor

Fixes #435.

A half-sent HTTP request held the process after SIGTERM: axum's graceful shutdown waits for in-flight connections, and hyper's waits for an unfinished request head. The serve now has two seconds from the signal to drain its connections; past that the serve future is dropped and the OTLP flush below still runs.

A row in binary_shutdown.rs holds a half-sent request across SIGTERM and proves the flush ran: the deadline warn is logged at the deadline and only the shutdown flush can deliver it before the process exits. The row fails without the fix (the process stays up past the 5 s exit bound) and passes with it in 2.8 s, 5/5 runs. Full gate green (fmt, clippy, clippy --features gen, doc, cargo test --workspace, cargo deny).

axum's graceful shutdown waits for every connection with a request
in progress, and hyper's waits for an unfinished request head to
complete. A half-sent request therefore held the process after
SIGTERM until the peer closed it, and only the supervisor's stop
timeout ended it, skipping the OTLP flush (plusky#435). The serve now
has two seconds from the signal to drain its connections; past
that the serve future is dropped and the OTLP flush below still
runs.

A row in binary_shutdown.rs holds a half-sent request across
SIGTERM and proves the flush ran: the deadline warn is logged at
the deadline and only the shutdown flush can deliver it before
the process exits.
@scarabeusiv

Copy link
Copy Markdown
Contributor Author

@plusky ready for review — the fix plus the regression test, full gate green.

@plusky plusky left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve — aggregated OCR + adversarial/security review (single review as requested).

OCR (native, range 7bab7fc..fefcfae): 0 findings, both files reviewed.

Adversarial + security, all verified locally:

  • Fail-before proven: with the fix reverted (test kept), the new row fails exactly as described — the process stays up past the 5 s exit bound. With the fix it passes in ~2.3 s. The test pins the bug, not the implementation.
  • Deadline arming is correct: the oneshot fires only inside the post-signal callback, and the serve cannot resolve before the signal (it only completes after graceful drain), so the 2 s bound cannot arm early; let _ = send() tolerates the already-resolved case, and a pre-signal serve error keeps the pre-existing ? path.
  • Audit durability strictly improves: dropping the serve past the deadline abandons stuck connections, but the OTLP shutdown flush below still runs — proven by the test (the warn is delivered to the mock collector). The alternative was hanging past the supervisor timeout into SIGKILL with no flush at all.
  • No secret in the new surface: the warn is static text plus a Duration; the OTLP endpoint env override lives in test-only harness code after the ambient scrub.
  • DESIGN stays accurate: the HTTP-serving note (shutdown cancels ct, #114) and the shutdown test rows are unchanged in meaning; no stamped claim contradicts the bound, so no DESIGN update needed.
  • Helper refactor is behavior-preserving: spawn_with_io_env only threads extra env through the existing spawn path; existing callers pass &[].

All 19 CI checks green on the head. Merging.

@plusky
plusky merged commit 5922b60 into plusky:main Nov 20, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server: an unfinished http request keeps the process alive after SIGTERM

2 participants