grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.45k stars 760 forks source link

gRPC errors in nice-grpc-web come back as undefined in angular 18 in optimized builds with zonejs #1431

Closed davidfiala closed 1 month ago

davidfiala commented 1 month ago

I'm not sure when this may have crept in, but I'm noticing that gRPC errors sent back from Envoy are being thrown as from the gRPC stub as undefined instead of ClientError when they come back from a nice-grpc-web method stub. gRPC errors come back correctly for the exact same gRPC request and response (as viewed in network inspector panel) if you aren't in angular prod build, with optimizations, or with zonejs all at once.

This occurs with:

If I switch off zonejs or optimizations, then nice-grpc-web stubs return gRPC errors like normal.

I got a hint to try turning off zonejs because I found that the stack trace was so incredibly obfuscated in my browser, even when I enabled sourcemaps. Fortunately angular 18 is the first version that (mostly) supports zoneless. Once I turned it off, I noticed that gRPC ClientErros are being thrown properly again.

I suspect that there's a chance this is more of a zonejs issue than a nice-grpc issue, but in either case even if this gets closed, I wanted to drop my experience here in case anyone else is searching for a similar issue.

davidfiala commented 1 month ago

I'm sorry - I had the wrong repos open and I meant to post this one in https://github.com/deeplay-io/nice-grpc Closing.

sampajano commented 1 month ago

@davidfiala No worries! :) Thanks for bringing this project to our awareness too btw.. πŸ˜„ We're also doing a Typescript migration so maybe we could learn a few things or 2 where it did right 😊