chore(async): track fire-and-forget goroutines, drain on shutdown#696
Merged
Conversation
Every detached go func() on the request path (email/SMS send, webhook events, audit log writes) now runs through internal/asyncutil.Go instead of a bare goroutine: - server.Run() waits for all of them to finish (asyncutil.Wait) after the HTTP/metrics listeners stop accepting, so a request's side effects aren't silently dropped mid-flight on shutdown. - asyncutil.Go recovers any panic in the closure and logs it, since an unrecovered panic in a bare goroutine takes down the whole process, not just the one request.
pull Bot
pushed a commit
to bhardwajRahul/authorizer
that referenced
this pull request
Jul 22, 2026
Added to README: - WebAuthn / passkey login - Enterprise SSO (SAML 2.0 IdP & SP, OIDC broker, verified domains, home realm discovery) - SCIM 2.0 provisioning - Multi-tenant / org-scoped admin - Migration guides (planned) Added to CHANGELOG [Unreleased]: - Service accounts as FGA subjects (authorizerdev#665) - SAML ACS CSRF exemption fix (authorizerdev#666) - Trusted-issuer token review config (authorizerdev#667) - Session revocation on password reset (authorizerdev#669, authorizerdev#673) - Multi-tenant SSO phases (authorizerdev#672, authorizerdev#674, authorizerdev#675) - OIDC discovery caching + Twitter PKCE fix (authorizerdev#668) - WebAuthn passkey support (authorizerdev#671) - Per-user TOTP lockout + hashed recovery codes (authorizerdev#670) - Server-side user search + org membership (authorizerdev#678, authorizerdev#680) - Per-method MFA availability signals (authorizerdev#681) - Consolidated MFA redesign narrative (authorizerdev#682-686) - SAML 2.0 IdP role (authorizerdev#691) - OAuth 2.1 / MCP hardening (authorizerdev#693) - SCIM group provisioning + FGA + SAML assertions (authorizerdev#694) - Provider template parity (authorizerdev#695) - Recent fixes (async tracking, AGENTS.md rules, security fixes, storage parity, error typing, panics, frontend fixes) (authorizerdev#696-702)
pull Bot
pushed a commit
to bhardwajRahul/authorizer
that referenced
this pull request
Jul 22, 2026
The initial 2.4.0 changelog pass covered authorizerdev#698-authorizerdev#702 but missed authorizerdev#696 (asyncutil goroutine tracking + panic recovery) — a real reliability improvement, not just internal tooling, worth calling out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Detached
go func()calls on the request path (email/SMS send, webhookevents, audit log writes) were invisible to graceful shutdown and, if they
panicked, took down the entire process — not just the one request.
What
internal/asyncutilpackage:Go(log, fn)tracks the goroutine andrecovers any panic;
Wait(log)blocks until all tracked goroutines finish.internal/service/,internal/http_handlers/,and
internal/audit/now goes throughasyncutil.Goinstead of a barego func().internal/server/server.gocallsasyncutil.Waitafter the HTTP/metricslisteners stop, before the process exits.
ctx(listeners, ticker-based cacheeviction) are untouched — they don't need draining.
Test plan
go build ./...,go vet ./...internal/asyncutilunit tests (drain + panic-recovery)TEST_DBS=sqlite go test -p 1 ./internal/...— full suite green