Skip to content

recover from panics in http handlers - #973

Merged
alpinskiy-top merged 1 commit into
masterfrom
malpinskiy/work
Sep 24, 2026
Merged

alpinskiy-top merged 1 commit into
masterfrom
malpinskiy/work

Conversation

@alpinskiy-top

Copy link
Copy Markdown
Collaborator

A panic in a handler goroutine used to abort the connection without a response (502 on the load balancer), and a panic in a goroutine spawned by a handler crashed the whole process.

  • add a recovery middleware that logs the panic, counts it and responds with HTTP 500
  • run goroutines spawned by handlers with conc.WaitGroup so their panics are propagated to the request goroutine
  • recover in mempool emulation goroutines
  • fix a data race on err in spam filter goroutines

A panic in a handler goroutine used to abort the connection without a
response (502 on the load balancer), and a panic in a goroutine spawned
by a handler crashed the whole process.

- add a recovery middleware that logs the panic, counts it and responds
  with HTTP 500
- run goroutines spawned by handlers with conc.WaitGroup so their panics
  are propagated to the request goroutine
- recover in mempool emulation goroutines
- fix a data race on err in spam filter goroutines

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@alpinskiy-top
alpinskiy-top merged commit 4542e8e into master Sep 24, 2026
1 check passed
@alpinskiy-top
alpinskiy-top deleted the malpinskiy/work branch September 24, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant