Skip to content

No graceful connection draining on shutdown in Rust (and TS): in-flight requests dropped on SIGTERM #28

Description

@abienkowski

Summary

On SIGTERM/SIGINT, the Go implementation drains in-flight requests via http.Server.Shutdown with a 30s timeout (go/main.go:92-97). The Rust implementation breaks its accept loops and exits main, which drops the tokio runtime — and with it any in-flight serve_connection tasks, aborting responses mid-flight.

Found during the code review of #27 (which rewrote the Rust shutdown path but preserved this pre-existing behavior — it is not a regression from that PR; the old single-listener code behaved the same way).

Affected implementation(s)

  • Rust
  • Go (reference behavior — already drains)
  • TypeScript (worth auditing while at it: confirm server.close() semantics wait for in-flight requests)

Expected behavior

On shutdown signal:

  1. Stop accepting new connections (already done).
  2. Allow in-flight requests to complete, up to a 30s deadline (matching Go).
  3. Exit after drain or deadline, whichever comes first.

Suggested fix (Rust)

Track connections in a tokio::task::JoinSet (or a counter + notify), and on shutdown call hyper's Connection::graceful_shutdown on active connections, then await the set with tokio::time::timeout(Duration::from_secs(30), ...).

Context

Split out from the review follow-ups on PR #27. Related: #25.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: P2Added to issues and PRs relating to a medium severity bugs.Type: EnhancementAdded to issues and PRs when a change includes improvements or optimizations.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions