A failed HTTP listen is only logged, and the server runs on without its HTTP API #167

Closed
opened 2026-10-20 21:49:15 +02:00 by clawbot · 0 comments
Collaborator

internal/server/server.go starts the HTTP server from its start hook with go srv.serve(). serveUntilShutdown calls ListenAndServe; when that fails (the port is taken, or the address cannot be bound) it logs listen error and cancels the server's own context, and serve returns. Nothing tells fx, so the process keeps running: the IRC listener and every other component stay up, the exit status is never set, and the HTTP API and web client are simply missing. A supervisor or container sees a healthy process. Found by the worker on #166, read from the code on 292f1eb.

Fix: bind the listener in the start hook (net.Listen with the configured address), so a failed bind returns an error from OnStart and fx stops startup and exits non-zero; then serve that listener in a goroutine. An error from serving after a successful bind (not http.ErrServerClosed) shuts the app down through fx.Shutdowner with a non-zero exit code.

Definition of done

  1. With the HTTP port already taken, neoircd exits non-zero at startup with an error naming the address.
  2. A test in internal/server that starting the server on a taken port returns an error from the start hook.
  3. One reviewed PR against next.

Model: opus-5-5

`internal/server/server.go` starts the HTTP server from its start hook with `go srv.serve()`. `serveUntilShutdown` calls `ListenAndServe`; when that fails (the port is taken, or the address cannot be bound) it logs `listen error` and cancels the server's own context, and `serve` returns. Nothing tells fx, so the process keeps running: the IRC listener and every other component stay up, the exit status is never set, and the HTTP API and web client are simply missing. A supervisor or container sees a healthy process. Found by the worker on https://git.eeqj.de/sneak/neoirc/pulls/166, read from the code on `292f1eb`. Fix: bind the listener in the start hook (`net.Listen` with the configured address), so a failed bind returns an error from `OnStart` and fx stops startup and exits non-zero; then serve that listener in a goroutine. An error from serving after a successful bind (not `http.ErrServerClosed`) shuts the app down through `fx.Shutdowner` with a non-zero exit code. ## Definition of done 1. With the HTTP port already taken, `neoircd` exits non-zero at startup with an error naming the address. 2. A test in `internal/server` that starting the server on a taken port returns an error from the start hook. 3. One reviewed PR against `next`. Model: opus-5-5
clawbot self-assigned this 2026-10-20 21:49:15 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/neoirc#167