Hacker News new | past | comments | ask | show | jobs | submit login
gRPC on Node.js with Buf and TypeScript (slavovojacek.medium.com)
73 points by balek on Nov 5, 2020 | hide | past | favorite | 14 comments



The protobuf/grpc ecosystem in nodejs in a catastrophic state compared to other languages. Half of our stack is in go using grpc, but the other half is nodejs. We tried protoc-js/protobufjs neither of them works with even a slightly more complicated setup. A simple import sometimes can cause invalid code, or just simply breaks the build. The best solution is now to use stephenh/ts-proto which works great, except the lack of grpc and json_name (which is must because we often use json for node services) support.


We have a two services in production that use node/grpc, both as clients and as servers and have seen very few issues. We have seen some library issues related to old versions of the now "legacy" protobuf implementation, but my understanding is that is being replaced with this implementation: https://github.com/grpc/grpc-node/tree/master/packages/proto...


So much this. At a previous company (Go/Python/Ruby), we used gRPC almost exclusively, and the experience was pretty good.

We're just now hitting a growth point where we need stronger contracts between our services and unfortunately really can't recommend gRPC as the primary language used is TypeScript.

We've spiked on our own protoc plugin (based on protoc-gen-star) and runtime lib (extending the google libs), but it's slow going and more likely to become tech debt than picking something off the shelf like open-api.


We built a 3-language system where we used grpc-web with Angular, a Go service, a few JVM services, and 2 experimental Rust services; with grpc.

I'd suggest investing in the time to get the compilation tooling fine on the TS side, then the process tends to be smooth enough.


> protoc-js/protobufjs neither of them works with even a slightly more complicated setup

Feel this quite a bit. Annotations completely blow up protobufjs for some reason, no idea why and no desire to fix upstream. Very unfortunately bad user experience.


Yes.

In my case the client lib works ok, but the server part is is not good (both ends nodejs/grpc/proto). I kept back the server part on older node version (13.3) to avoid issues. Also I had issues with pm2 with the server part.


i wish GRPC had a better escape hatch, so if my language doesn't support it or I only need one endpoint, I can just consume a GRPC service via a regular REST HTTP request.


That's available with GRPC to JSON transcoding https://github.com/grpc-ecosystem/grpc-gateway


It can also emit swagger/OpenAPI v2, so you can then consume that API easily!


grpc-web makes this pretty easy.

I don't think I would recommend the grpc-gateway project for new projects. It's there and it works, but the momentum seems to be behind grpc-web these days, and, personally, I find it a bit easier to get off the ground with it.



Why did you make the choice to go with protobuf?


It sometimes seems the word “scalable” has completely lost its meaning. This is a basic barebones build process, not a “scalable” build process, whatever that means.


This title needs more debatably functional webstack components.

Thank god there's gonna be a 2nd part.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: