Skip to content
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

Handle google protobuf well known types #47

Open
rocketraman opened this issue Dec 28, 2017 · 7 comments
Open

Handle google protobuf well known types #47

rocketraman opened this issue Dec 28, 2017 · 7 comments

Comments

@rocketraman
Copy link

The protobuf "well-known types" (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf) are included in every language runtime, including the npm package (see protocolbuffers/protobuf#1638).

Currently, grpcc requires proto files that import a well-known type to have a copy of the well-known type locally, otherwise you get an Error: failed to import '...' in './foo.proto': file not found error.

These well-known types should be handled automatically by importing them from the protobuf npm package instead.

@drigz
Copy link

drigz commented Mar 15, 2018

I've looked in to this a bit. grpcc uses grpc-node which in turn uses protobuf.js to load proto files. protobuf.js seems not to plan to have special support for the well known types (protobufjs/protobuf.js#447). protobuf.js v6 adds support for changing how paths are resolved (protobufjs/protobuf.js#368 (comment)) which would allow grpcc to add logic to import from multiple paths, but grpc-node rolled back their change to use v6 (grpc/grpc-node#103). So it seems this can't easily be done.

I've worked around it with a symlink in the root of my repo:

ln -s $HOME/git/google/protobuf/src/google google
echo "/google" >> ~/.gitignore

@jeffzoch
Copy link

jeffzoch commented May 4, 2018

Just wanted to point grpc/grpc-node#103 has been closed with the addition of @grpc/proto-loader and thus this issue can be fixed I believe.

@valentindotxyz
Copy link

Hhm, I still have this issue as of today :(

@lzuwei
Copy link

lzuwei commented May 17, 2018

facing the same issue as well

Error: failed to import 'path/to/my/service/pb/google/protobuf/empty.proto' 

@claudiocabral
Copy link
Contributor

claudiocabral commented Jun 5, 2018

I started working on a fix, using @grpc/proto-loader but the backwards compatibility is not great. I got it to work, but we lose all information about the message types and I'm not quite sure it actually works (so far my test messages come back empty)

@jfyne
Copy link
Contributor

jfyne commented Jul 18, 2018

@claudiocabral I built on your start and finished it off with #61

@jfyne
Copy link
Contributor

jfyne commented Jul 18, 2018

I have also created a docker image with built in common protobuf includes here which includes the @grpc/proto-loader code. I use it with google/protobuf/timestamp.proto successfully.

https://hub.docker.com/r/jfyne/grpcc/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants