fix(server): gracefully shut down HTTP proxy to drain in-flight requests

On signal, main waited on wg for StartHTTPProxy's server.Listen, which never
returns because nothing called server.Shutdown(); it timed out after 10s and
process-exited, abruptly killing in-flight GraphQL requests.

Expose the proxy Fiber app and register an http-proxy Shutdown component so
server.Listen returns after Shutdown, letting connections drain. Guard the
shared app handle with a mutex (written by the StartHTTPProxy goroutine, read
by the shutdown component). Verified with build, vet, full test and full
race suite.
This commit is contained in:
2026-08-13 02:37:14 +01:00
parent d04ab329a1
commit db2216973e
3 changed files with 92 additions and 0 deletions
+4
View File
@@ -612,6 +612,10 @@ func main() {
return nil
})
// Register HTTP proxy so in-flight requests drain gracefully on shutdown
// instead of being cut off when the process exits.
shutdownManager.RegisterComponent("http-proxy", shutdownHTTPProxy)
// Cache shutdown is handled internally by the cache implementation
// Start monitoring server