-
Notifications
You must be signed in to change notification settings - Fork 636
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
enums not exported by grpc-protobufjs #478
Comments
Have you checked the documentation of the new package about the various options available to pass to the loader, especially the part about enums? https://www.npmjs.com/package/@grpc/proto-loader |
Yes I have. I have, in exasperation, tried all options for |
The options you're referring to control how enum values are returned when deserializing messages. They do not change what type information is provided when parsing the proto file. The |
Wait. Was this even available in grpc.load? |
I believe we are in agreement there.
Yes. See the code example I pasted in my initial bug report. |
Right. The original behavior was then unfortunately a side effect from using protobufjs 5 that was probably leaking these out. It was never intended to leak any part of the proto definition beside the actual service definition. This isn't something we're going to change. The deprecation notice will stay in effect until we release an hypothetical grpc 2.0, in which case it'll be removed. But also, grpc.load will still use the older protobufjs 5.0.3, while @grpc/proto-loader will somewhat use the latest version of protobufjs. The solution for you if you want to have access to the contents of the proto definitions is to use protobufjs directly. I'm closing this one as a "won't fix". |
Problem description
When using the now-deprecated
grpc.load
, enums are exported and available in JS. When using@grpc/proto-loader
, they are not.Reproduction steps
Consider this simple .proto file:
As best as I can tell from the interfaces exported by
grpc-protobufjs
(https://github.com/grpc/grpc-node/blob/master/packages/grpc-protobufjs/src/index.ts), it looks likeloadSync
will never return enums.At least according to protobufjs/protobuf.js#576, after loading the root and calling
resolveAll
, enums should be available vialoadedRoot.lookup
, butloadSync
doesn't export the root so callers can't access them.Environment
The text was updated successfully, but these errors were encountered: