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

Error: unresolvable extensions: 'extend google.protobuf.FieldOptions' when running server.js #17

Open
SachinHg opened this issue May 31, 2019 · 2 comments

Comments

@SachinHg
Copy link

SachinHg commented May 31, 2019

Hi,
I have a proto file which uses google.protobuf.FieldOptions and it fails compailing that protobufjs 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

@SachinHg SachinHg changed the title Support for using proto file with imports Error: unresolvable extensions: 'extend google.protobuf.FieldOptions' when running server.js May 31, 2019
@jkryl
Copy link

jkryl commented Mar 18, 2020

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.

@tajpouria
Copy link

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");

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

3 participants