A failed listen leaves a live, non-serving process that fx still reports RUNNING #200

Closed
opened 2026-08-20 05:46:55 +02:00 by clawbot · 0 comments
Collaborator

Start a second instance while the port is bound and the process does not exit. Observed, then it sat there for 183 s:

{"level":"INFO","msg":"http begin listen","listenaddr":":18080"}
{"level":"ERROR","msg":"listen error","error":"listen tcp :18080: bind: address already in use"}
[Fx] RUNNING

Cause: Server's fx OnStart hook returns nil immediately and runs s.Run() in a goroutine (internal/server/server.go:104-116). The listen error only calls s.cancelFunc() (internal/server/http.go:43-50), which ends serve()'s wait but never invokes fx.Shutdowner, so the process stays alive with no listener.

Operational impact: systemd Restart=on-failure and Docker restart policies never fire. The service is down and looks up. It is also the precondition for the duplicate-delivery defect filed alongside this one.

Definition of done:

  • a listen failure calls fx.Shutdowner.Shutdown() (or equivalent) so the process exits non-zero
  • PORT bound by another process: a second start exits non-zero within a second or so, and logs the bind error
  • a regression test asserts the process terminates on listen failure rather than reporting RUNNING
  • no change to the clean-shutdown path: docker stop still drains within the existing grace window
Start a second instance while the port is bound and the process does not exit. Observed, then it sat there for 183 s: ``` {"level":"INFO","msg":"http begin listen","listenaddr":":18080"} {"level":"ERROR","msg":"listen error","error":"listen tcp :18080: bind: address already in use"} [Fx] RUNNING ``` Cause: `Server`'s fx `OnStart` hook returns `nil` immediately and runs `s.Run()` in a goroutine (`internal/server/server.go:104-116`). The listen error only calls `s.cancelFunc()` (`internal/server/http.go:43-50`), which ends `serve()`'s wait but never invokes `fx.Shutdowner`, so the process stays alive with no listener. Operational impact: systemd `Restart=on-failure` and Docker restart policies never fire. The service is down and looks up. It is also the precondition for the duplicate-delivery defect filed alongside this one. Definition of done: - a listen failure calls `fx.Shutdowner.Shutdown()` (or equivalent) so the process exits non-zero - `PORT` bound by another process: a second start exits non-zero within a second or so, and logs the bind error - a regression test asserts the process terminates on listen failure rather than reporting RUNNING - no change to the clean-shutdown path: `docker stop` still drains within the existing grace window
clawbot added this to the 1.0.0 milestone 2026-08-20 05:46:55 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#200