Howdy
We have recently refactored a few of our services to use net/http instead of home-grown TCP sockets and gob. The reduction in code was awesome.
We started out 3 years ago by building code that following some approximation to an actor model, where we recovered panics so that errors inside individual actors didn't kill the OS process.
We have since discarded this model. It was always difficult to distinguish between panics that were just an error and panics that should actually terminate the OS process due to it arriving in an insane state.
We've found that we more quickly achieved robust services when we didn't recover panics, since it immediately became apparent when a service panicked and we could spot it and fix it.
We use systemd to supervise our services, so we're not that worried about a rare panic blowing away our process. We prefer it. It makes our mistakes more visible to us.
With all this being said, we would like to be able to turn off net/http's recovery of panics. We prefer for our service to crash if there is a panic handling a request.
The recover stuff is baked in quite deep. I guess we'd be happy with putting code like:
func init() {
http.RecoverPanics = false
}
in our services. But I'm guessing you might find this quite gross.
An alternative might be to add a Recover bool to the Server type. It can probably pass from Server to conn in newConn.
Any suggestions on how to approach this, if you agree that it should be approached? I'd be happy to prepare a CL.
Regards
Albert