grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

Can't compile and produce the js file for proto with inner "["

Open ievseev opened this issue 4 years ago • 6 comments

Hi! I have error with compiling .proto having inner "[" char when use custom mountebank:

`error: [2021-11-11T11:36:31.231Z] - [grpc:4542] /app/node_modules/@ozonru/mountebank-grpc/src/mock.js:40 throw new ProtoError(serviceOptions.file, error.message) ^

ProtoError: Could not loading a proto file "my_service.proto". Have you added a path with vendor's proto files to request? Error message: illegal value '[' (protos/my_service/my_service.proto, line 440) at /app/node_modules/@ozonru/mountebank-grpc/src/mock.js:40:19 at Array.forEach () at Object.getServerInstance (/app/node_modules/@ozonru/mountebank-grpc/src/mock.js:31:37) at Server. (/app/node_modules/@ozonru/mountebank-grpc/src/index.js:22:41) at Object.onceWrapper (events.js:420:28) at Server.emit (events.js:314:20) at emitCloseNT (net.js:1657:8) at processTicksAndRejections (internal/process/task_queues.js:83:21)`

In proto on line 440 file we have field: int64 some_id = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {required: ['some_id']}];

I assume it may be related to this.

Could you help to solve this problem?

ievseev avatar Nov 11 '21 18:11 ievseev

most likely error in method loadSync

ievseev avatar Nov 11 '21 18:11 ievseev

Running into this too

pytlesk4 avatar Nov 12 '21 22:11 pytlesk4

The @grpc/proto-loader library just calls out to protobufjs to parse .proto files. You should file an issue there about this error.

murgatroid99 avatar Nov 12 '21 22:11 murgatroid99

@murgatroid99 protobufjs fixed problem with '[' but it was in version after 5.0.3. Is it possible to update protobufjs version to latest (6.11.2)?

ievseev avatar Nov 15 '21 10:11 ievseev

Fortunately, @grpc/proto-loader depends on protobufjs version ^6.10.0, so it should install the latest version.

Though, if the protobufjs issue you linked in the initial issue post is the cause of this issue, then it's actually an open bug that hasn't been fixed yet, which would explain why @grpc/proto-loader has not picked up a fix yet.

murgatroid99 avatar Nov 15 '21 16:11 murgatroid99

This is resolved on the master branch in protobufjs but not yet released. You can pin (or use a resolution) the protobufjs package to commit d13d5d5688052e366aa2e9169f50dfca376b32cf in the meantime to work around it.

I'm going to open up an issue in protobufjs to try and get a new release cut (https://github.com/protobufjs/protobuf.js/issues/1711).

Drew-Kimberly avatar Apr 25 '22 13:04 Drew-Kimberly