Open SachinHg opened 5 years ago
I had the same problem and needed the following workaround to make it work. When loading the proto file you need to specify include file with definition of FieldOptions. This works assuming that protobufjs is a dependency of your project and that your script is in top-level directory of your project.
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: false,
longs: Number,
enums: String,
defaults: true,
oneofs: true,
// this is to load google/descriptor.proto, otherwise you would see error:
// unresolvable extensions: 'extend google.protobuf.FieldOptions' in .csi.v1
includeDirs: [__dirname + '/node_modules/protobufjs'],
});
Also it's not a defect in grpc-mock package as this error appears anytime loading a proto file with such definition.
import { status } from "grpc";
import { createMockServer } from "./grpc-mock";
const mockServer = createMockServer({
protoPath: "proto/login/loginpb/login.proto",
options: {
includeDirs: ["proto"],
},
packageName: "loginpb",
serviceName: "LoginService",
rules: []
});
mockServer.listen("0.0.0.0:50051");
Hi, I have a proto file which uses
google.protobuf.FieldOptions
and it fails compailing thatprotobufjs
cannot resolve this. Pasted the error below:/node_modules/protobufjs/src/root.js:243 throw Error("unresolvable extensions: " + this.deferred.map(function(field) {
Any idea how to make protobufjs support this? Thanks