-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch from protobufjs to google-protobuf #1327
Comments
Hello @renkei, what about perfomance? Is it fast enough? |
I didn't recognized any perfomance issues so far. But, to be honest, I didn't executed any benchmarks or something similar. Since JavaScript is an officially supported language by Google's proto compiler I would expect that Google has done some optimizations an will continuously optimize whereever possible. However, if someone has some benchmark results or other hints, I'm always interested in. |
I am currently building a distributed system where most components use the standard protoc compiler with TypeScript definitions generated via a plugin (https://www.npmjs.com/package/ts-protoc-gen), but I still have a use for protobufjs because it provides some functionality that protoc compiler does not; most importantly it can load protobuf files at runtime, and use these to decode (or encode) messages. Unless I'm missing something, this is not really possible with the "normal" google-protobuf compiler? |
@renkei What about that there's no equivalent (that I can see) for an The |
Hi I am trying to do the opposite. I am noticing google-protobuf can be slow in some scenarios so i am experimenting with protobufjs. Are the benchmarks listed in this repo still valid as of the latest version of google-protobuf? is it worth it? |
I'd also be interested in a performance comparison with (the compiled version of) |
We're actually switching in the other direction because google-protobuf for JS doesn't follow the canonical proto3 -> JSON mapping, and protobufjs does. However I do find that having the central interfaces of jspb.Message etc is incredibly useful, and I wish protobufjs had something similar. |
@alexcardell are you sure that's the case? There are number of open issues (e.g. #1304) here about the lack of support for canonical proto3 <-> JSON mapping. Would love to know if you're experiencing otherwise. |
I suppose I meant that within our use cases (as well as the fact the JSON usage is an intermediate step) the mapping seems fine, unlike |
hello, i set [jstype = JS_STRING],but not working in js, the d.ts is working,so I want to know are you has this problem? |
google-protobuf is total mess with a lot of opened issues and wrong javascript code generation. Do not recommend to use |
One thing that is annoying is that you can convert the protobufs to json with toObject which works well with Redux. However a big gotcha is there is no conversion fromObject method. So you have to build a whole separate middle layer to convert it back. Or else pass the whole protobuf around instead of passing around smaller bits of state. |
I've also faced inconvenience with Finally I've stayed on
Maybe you find it useful: https://gist.github.com/vitalets/c52c3efa40fc1154ccc6639903758565 |
For those looking for JSON serialization with |
您好,您的来信我已经收到,请等待回复!
|
protobuf.js version: 6.8.8
This is rather an experience report than an issue. But maybe, this is helpful for some of you.
Since this project seems not to be maintained anymore and makes more and more trouble (see the increasing count of issues here) when used with Node.js 12 or newer, I've decided to replace protobufjs with the original protobuf runtime maintained by Google, it's the npm package google-protobuf.
Short result:
Long result:
In the end, after some work, it works without any further issues. I can use protoc now for all programming language targets like C++, C# and even JavaScript and TypeScript (with the grpc-web plugin), not that bad.
It's a little bit sad because protobuf.js was a great community project. But for now, I would try to avoid it and maybe my remarks are helpful to find an alternative way.
The text was updated successfully, but these errors were encountered: