Re:gRPC on Node.js with Buf and TypeScript
by theanotherdev on Thursday November 05, 2020 @11:29AM
(#24999561)
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.
Re:gRPC on Node.js with Buf and TypeScript
by be_erik on Thursday November 05, 2020 @12:10PM
(#24999892)
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...
Re:gRPC on Node.js with Buf and TypeScript
by mothershipper on Thursday November 05, 2020 @12:04PM
(#24999849)
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.
Re:gRPC on Node.js with Buf and TypeScript
by gravypod on Thursday November 05, 2020 @01:49PM
(#25000782)
> 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.
Re:gRPC on Node.js with Buf and TypeScript
by mhaberl on Thursday November 05, 2020 @11:41AM
(#24999649)
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.
Re:gRPC on Node.js with Buf and TypeScript
by natchy on Thursday November 05, 2020 @12:01PM
(#24999828)
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.
Re:gRPC on Node.js with Buf and TypeScript
by mumblemumble on Thursday November 05, 2020 @03:13PM
(#25001522)
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.
Re:gRPC on Node.js with Buf and TypeScript
by pdpi on Thursday November 05, 2020 @12:48PM
(#25000250)
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.
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.
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.
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.
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 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.
Thank god there's gonna be a 2nd part.