Server calls cleanShutdown() twice causing potential errors #21
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/webhooker#21
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
The
Server.cleanShutdown()method can be called twice during shutdown:serve()when the context is cancelled:<-s.ctx.Done()→s.cleanShutdown()OnStophook:s.cleanShutdown()This results in
httpServer.Shutdown()being called twice. Whilehttp.Server.Shutdown()is likely idempotent, this is fragile and can produce spurious error logs.Additionally, there's a potential race condition: if fx sends SIGTERM and the internal signal handler fires simultaneously, both goroutines could call
cleanShutdown()concurrently without synchronization (no mutex or sync.Once).Fix
Wrap
cleanShutdown()in async.Onceto ensure it runs exactly once:Category
Should-fix.