-
Notifications
You must be signed in to change notification settings - Fork 765
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
MethodDescriptor Introduced in #567 is broken #596
Comments
Yep, I'm also experiencing this error. It seemed to work in 1.0.4 |
Same here, used to work with 1.0.4 |
Sorry for being late to look into this. I just looked into this - but it appears that the issue may run deeper than I thought. At first I thought it's some DOA issue that borking everything but it's not. I run the 1.0.5 plugin on the helloworld example and it works. Then I realized the helloworld example uses So I tried the Echo ts-example next, since that uses
So I wonder what's the difference between your Can you post your relevant section of the |
Hey stanley, I'm going to have a look at the scenario as soon as possible. I got a When the service uses the models (with package name ofcourse) models: package models;
message Test{} svc.proto package svc;
import "models.proto";
message SvcTest{
models.Test test = 1;
}
service TestSvc {
rpc Foobar(SvcTest) returns (models.Test);
} edit: at least this is the special part about my proto setup |
@buehler Thanks. With these imports, I am able to verify the problem
It is still a bit unclear to me, why with |
@stanley-cheung fantastic news, thanks for the fix! When are you looking to cut a new release? |
Hopefully soon. I am trying to see if I can add a test to prevent this from happening again in the future |
Hey @stanley-cheung Since this is an error in javascript and the typescript definitions are fine, neither // foobar.d.ts
export class Foobar {} // foobar.js
module.exports = {}; If you use this file in typescript and compile it, you could "instantiate" a Foobar class. The compile would not throw an error, but when you actually run the code, Foobar will not be defined. This is a runtime error that happens when the JIT of the browser does parse and compile the javascript code. // Definition... look how `service_pb` is loaded.
var models_pb = require('./models_pb.js')
const proto = {};
proto.service = require('./service_pb.js');
const methodDescriptor_Service_Demo = new grpc.web.MethodDescriptor(
'/service.Service/Demo',
grpc.web.MethodType.UNARY,
service_pb.ServiceModel, // <<<<< `service_pb` is not defined.
models_pb.DemoModel,
/** @param {!proto.service.ServiceModel} request */
function(request) {
return request.serializeBinary();
},
models_pb.DemoModel.deserializeBinary
); A purposed test that could help to prevent those errors (beside actually compile it with tsc or webpack) could be to load the actual code with a node vm. Maybe with something like https://www.npmjs.com/package/vm2. With this, you could be sure that the code actually runs through the JIT compiler of a js engine. I attached my findings and demo files for further analysis if needed. Cheers |
oh. just saw that you actually added the eval test 😁 |
@stanley-cheung would it be possible to get a released version anytime soon? |
@travikk Working on it |
Fixed in version |
@stanley-cheung amazing works, thanks. I can confirm it works for me now! |
/cc @stanley-cheung
I'm running with
--grpc-web_out=import_style=commonjs+dts,mode=grpcweb
Here's a generated MethodDescriptor: note
optin_pb.OptInRequest
instead ofproto.x.protobuf.v1alpha2.OptInRequest
I'm unable to compile grpc-web anymore (no build instructions either..), however the problem seems around these lines
https://github.com/grpc/grpc-web/pull/567/files#diff-2e729f9088e537bfeb6fefc318963a96R1078
https://github.com/grpc/grpc-web/pull/567/files#diff-2e729f9088e537bfeb6fefc318963a96R1389
This line could use a comment to explain what's the goal of
method->output_type()->file() != file
The text was updated successfully, but these errors were encountered: