Fixed
- Webhook notifications never sent (#6)
Shutdown()now waits for in-flight HTTP requests to complete before exit- Added
defer webhookSvc.Shutdown(5s)toHandleHook()for graceful shutdown - Previously:
cancel()was called immediately, interrupting HTTP requests - Now:
cancel()is only called after completion or on timeout
Added
- E2E test
TestE2E_WebhookGracefulShutdown- deterministic graceful shutdown verification - Unit tests for
Shutdown()+SendAsync()combination - Updated
webhookInterfaceto includeShutdown(timeout)method
Technical Details
The root cause was that Shutdown() called s.cancel() immediately, which cancelled the context used by HTTP requests. This caused webhook requests to be interrupted before they could complete.
The fix moves cancel() to be called only:
- After all in-flight requests complete successfully, OR
- When the shutdown timeout (5 seconds) is reached
This ensures webhook notifications are reliably delivered before the process exits.
Fixes #6