fix(std/net/http): correct server lifecycle #1478

Merged
vyzo merged 3 commits from jay/gerbil:bug-http-server-lifecycle into v0.19-staging 2026-09-01 23:05:57 +00:00
Member

HTTP server shutdown can hang because listener EBADF errors are retried and condition-variable timeout results are ignored. Peer disconnects during server-owned response closing are also logged as unhandled handler failures.

This PR makes EBADF terminal, enforces the shutdown deadline, caches listener addresses before closure, and contains only EPIPE/ECONNRESET from response finalization.

HTTP server shutdown can hang because listener `EBADF` errors are retried and condition-variable timeout results are ignored. Peer disconnects during server-owned response closing are also logged as unhandled handler failures. This PR makes `EBADF` terminal, enforces the shutdown deadline, caches listener addresses before closure, and contains only `EPIPE`/`ECONNRESET` from response finalization.
vyzo approved these changes 2026-08-31 13:55:56 +00:00
Dismissed
vyzo left a comment

this looks good to me, only actionable is to log the error when we fail to start a listener.

also, if all listeners fail i think we should fail the start altogether.

this looks good to me, only actionable is to log the error when we fail to start a listener. also, if all listeners fail i think we should fail the start altogether.
@ -70,2 +70,4 @@
(def (do-server-start! (self : http-server))
=> :void
(def (start-listener! (sock : ServerSocket))
(with-error (ignore-errors (sock.close))
Owner

i think that at the minimum report errors -- you can use report-errors

i think that at the minimum report errors -- you can use `report-errors`
Owner

although i think it is better to log the errors in the syslog instead of the console. so a try/catch and a syslog.error is in order.

although i think it is better to log the errors in the syslog instead of the console. so a try/catch and a syslog.error is in order.
@ -180,3 +184,1 @@
error: (OSError-message e)
errno: (OSError-errno e))
(loop))
(if (fx= (OSError-errno e) EBADF)
Owner

any spurious other errors we might get?

also, let's make this a cond? slightly prettier.

any spurious other errors we might get? also, let's make this a cond? slightly prettier.
jay changed title from WIP: fix(std/net/http): correct server lifecycle to fix(std/net/http): correct server lifecycle 2026-09-01 21:54:22 +00:00
jay requested review from vyzo 2026-09-01 21:54:52 +00:00
vyzo approved these changes 2026-09-01 23:05:49 +00:00
vyzo left a comment

thank you!

thank you!
vyzo merged commit 5c055e8dab into v0.19-staging 2026-09-01 23:05:57 +00:00
vyzo deleted branch bug-http-server-lifecycle 2026-09-01 23:06:06 +00:00
Sign in to join this conversation.
No description provided.