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

Generated invalid code #306

Closed
mitar opened this issue Oct 4, 2018 · 4 comments · Fixed by #310
Closed

Generated invalid code #306

mitar opened this issue Oct 4, 2018 · 4 comments · Fixed by #310

Comments

@mitar
Copy link
Contributor

mitar commented Oct 4, 2018

I tried generating files based on the guide, and in my case it generates invalid output:

const grpc = {};
grpc.web = require('grpc-web');

var google_protobuf_descriptor_pb = require('google-protobuf/google/protobuf/descriptor_pb.js')

var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js')

var value_pb = require('./value_pb.js')
const proto = {};
proto. = require('./core_pb.js');

See the final line. So I have value.proto and core.proto files. I am using protoc 3.5.1, and today's master branch of this repo.

Also the final line is:

module.exports = proto.;
@mitar
Copy link
Contributor Author

mitar commented Oct 4, 2018

My .proto files do not have package defined.

@mitar
Copy link
Contributor Author

mitar commented Oct 4, 2018

So it seems it is not possible to generate code for service which is not inside a package. This is a problem because on the server side we have such code (in Python). If I add a package name on the client and not on the server (for compatibility with other clients) it does not work because method names are different. Client prefixes them with package name.

So the question is how to generate code without the package/outside of the package.

@stanley-cheung
Copy link
Collaborator

Will fix.

@mitar
Copy link
Contributor Author

mitar commented Oct 4, 2018

I now run the following commands which make it work:

sed -i 's/module\.exports = proto\.;/module.exports = proto;/g' core_grpc_web_pb.js
sed -i 's/const proto = {};/const proto =/g' core_grpc_web_pb.js
sed -i 's/proto\. = require/require/g' core_grpc_web_pb.js

In short, I replace:

module.exports = proto.;

with:

module.exports = proto;

And:

const proto = {};
proto. = require('./core_pb.js');

with:

const proto = require('./core_pb.js');

mitar added a commit to mitar/grpc-web that referenced this issue Oct 5, 2018
loyalpartner pushed a commit to loyalpartner/grpc-web that referenced this issue Sep 4, 2020
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 3.1.7 to 3.1.14. **This update includes security fixes.**
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](webpack/webpack-dev-server@v3.1.7...v3.1.14)

Signed-off-by: dependabot[bot] <support@dependabot.com>
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

Successfully merging a pull request may close this issue.

2 participants