On Sat, Jul 10, 2021 at 10:17 AM '
aar...@arista.com' via
grpc.io
<
grp...@googlegroups.com> wrote:
>
> I think the biggest issue is that you might not notice that your program was panicing because gRPC was handling it for you. I definitely want to know if panics are occurring in my code, because they are not expected.
>
> Also by not catching the panic, you as the user gets to decide how to handle it. It's up to you if you want to put a 'recover()' in your handler or let a panic crash your program. If grpc were to catch panics in handlers there isn't a simple way to opt out of that behavior (without adding another option to gRPC).
Thanks for sharing your thoughts. I created a test HTTP server and
added demonstration of the behavior here:
https://gist.github.com/amitsaha/ec7ce96e47bbfca0e7a52d5bff53485b to
better illustrate what i am referring to and in case it becomes useful
to somebody else.
So my understanding is that even with the recovery() mechanism in
place, the user will get to know when a panic has occurred unless the
ErrAbortHandler value is used to panic. The user can still implement
a middleware and not let the stdlib's panic handling mechanism get
invoked at all.
>
> Aaron
>
> On Sunday, July 4, 2021 at 3:20:30 AM UTC-7
amits...@gmail.com wrote:
>>
>> On Sun, Jul 4, 2021 at 10:31 AM Lars Seipel <
l...@slrz.net> wrote:
>> >
>> > On Sat, Jul 03, 2021 at 04:20:12PM -0700, Amit Saha wrote:
>> > >When writing HTTP servers in Go, a panic() in a request handler doesn't
>> > >abort the entire process as it has a recovery mechanism setup
>> > >(
https://golang.org/src/net/http/server.go?s=99233:99288#L81). With gRPC
>> > >it seems that's not the case - so i assume there is a good reason we don't
>> > >have a recover() in the goroutine executing the service handler. I was
>> > >curious if anyone knew what the reason was?
>> >
>> > The described behaviour in the net/http package is widely considered
>> > (including by its original author) to be a misfeature. Therefore, it
>> > only makes sense to not repeat the same mistake in gRPC.
>>
>> Thanks - do you have more details on this? I am interested to learn
>> why that's the case.
>>
>> >
>
> --
> You received this message because you are subscribed to the Google Groups "
grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
grpc-io+u...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/80fb5b92-3f5b-438e-aa8d-2510c71bfce8n%40googlegroups.com.