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

grpc-tools\bin\protoc_plugin.js:37 throw error;

Open long1eu opened this issue 1 year ago • 5 comments

Problem description

Running protoc_plugin.js result in an error I can't debug or solve.

Reproduction steps

protoc --js_out=import_style=commonjs,binary:backend\cloud-run\src\proto ^
       --ts_out=generate_package_definition:backend\cloud-run\src\proto ^
       --grpc_out=grpc_js:backend\cloud-run\src\proto ^
       --plugin=protoc-gen-grpc=C:\Users\app_lab\AppData\Roaming\npm\grpc_tools_node_protoc_plugin.cmd ^
       --proto_path=backend\cloud-run\assets\proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\announcements_likes_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\announcements_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\background_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\calendar_entries_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\chats_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\comments_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\common.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\feed_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\groups_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\legal_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\messages_likes_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\messages_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\method_auth.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\notifications_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\notification_tokens_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\pace_management_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\query.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\reports_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\squads_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\users_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\workout_likes_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\workout_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\workout_share_service.proto ^
       backend\cloud-run\assets\proto\app_lab\app\v1\workout_spec_service.proto ^
       backend\cloud-run\assets\proto\google\api\annotations.proto ^
       backend\cloud-run\assets\proto\google\api\client.proto ^
       backend\cloud-run\assets\proto\google\api\field_behavior.proto ^
       backend\cloud-run\assets\proto\google\api\http.proto ^
       backend\cloud-run\assets\proto\google\api\resource.proto ^
       backend\cloud-run\assets\proto\google\longrunning\operations.proto ^
       backend\cloud-run\assets\proto\google\protobuf\any.proto ^
       backend\cloud-run\assets\proto\google\protobuf\api.proto ^
       backend\cloud-run\assets\proto\google\protobuf\descriptor.proto ^
       backend\cloud-run\assets\proto\google\protobuf\duration.proto ^
       backend\cloud-run\assets\proto\google\protobuf\empty.proto ^
       backend\cloud-run\assets\proto\google\protobuf\field_mask.proto ^
       backend\cloud-run\assets\proto\google\protobuf\source_context.proto ^
       backend\cloud-run\assets\proto\google\protobuf\struct.proto ^
       backend\cloud-run\assets\proto\google\protobuf\timestamp.proto ^
       backend\cloud-run\assets\proto\google\protobuf\type.proto ^
       backend\cloud-run\assets\proto\google\protobuf\wrappers.proto ^
       backend\cloud-run\assets\proto\google\pubsub\v1\pubsub.proto ^
       backend\cloud-run\assets\proto\google\rpc\status.proto ^
       backend\cloud-run\assets\proto\google\type\date.proto ^
       backend\cloud-run\assets\proto\grpc\health\v1\health.proto

Environment

Additional context

C:\Users\app_lab\AppData\Roaming\npm\node_modules\grpc-tools\bin\protoc_plugin.js:37
    throw error;
    ^

Error: Command failed: C:\Users\app_lab\AppData\Roaming\npm\node_modules\grpc-tools\bin\grpc_node_plugin.exe

    at ChildProcess.exithandler (node:child_process:402:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Socket.<anonymous> (node:internal/child_process:458:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:301:12) {
  code: 3221225781,
  killed: false,
  signal: null,
  cmd: 'C:\\Users\\app_lab\\AppData\\Roaming\\npm\\node_modules\\grpc-tools\\bin\\grpc_node_plugin.exe'
}
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

long1eu avatar Jan 26 '23 10:01 long1eu

Is there a way to debug this?

long1eu avatar Jan 31 '23 10:01 long1eu

I have the exact same issue, and I can confirm this is an issue appearing with grpc-tools version 1.12.0. If I try the command with 1.11.3, it runs fine, but not with any of the 1.12 versions. So try running this: npm install -g [email protected]

Reproduced with both node v14.16.1 and the latest v19.6.0, both installed using nvm for Windows. I have the same issue wether I only type "grpc_tools_node_protoc" or I type the full command with arguments. I know the command syntax is correct, because my grpc_tools_node_protoc command used to work, but since I tried on a fresh Windows install, I can't get the command to work anymore. Also, I tried the static_codegen example it also fails.

Here is the output I get, identical as the OP:

C:\Users\robil\AppData\Roaming\nvm\v19.6.0\node_modules\grpc-tools\bin\protoc.js:41
    throw error;
    ^

Error: Command failed: C:\Users\robil\AppData\Roaming\nvm\v19.6.0\node_modules\grpc-tools\bin\protoc.exe --plugin=protoc-gen-grpc=C:\Users\robil\AppData\Roaming\nvm\v19.6.0\node_modules\grpc-tools\bin\grpc_node_plugin.exe --js_out=import_style=commonjs binary:../node/static_codegen/ --grpc_out=grpc_js:../node/static_codegen helloworld.proto

    at ChildProcess.exithandler (node:child_process:419:12)
    at ChildProcess.emit (node:events:512:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:512:28)
    at Pipe.<anonymous> (node:net:316:12) {
  code: 3221225781,
  killed: false,
  signal: null,
  cmd: 'C:\\Users\\robil\\AppData\\Roaming\\nvm\\v19.6.0\\node_modules\\grpc-tools\\bin\\protoc.exe --plugin=protoc-gen-grpc=C:\\Users\\robil\\AppData\\Roaming\\nvm\\v19.6.0\\node_modules\\grpc-tools\\bin\\grpc_node_plugin.exe --js_out=import_style=commonjs binary:../node/static_codegen/ --grpc_out=grpc_js:../node/static_codegen helloworld.proto'
}

Node.js v19.6.0

Any hints to make this command work with the latest versions?

robido avatar Feb 08 '23 21:02 robido

I'm not personally experiencing the issue, but a few days a go, a colleague also run into this.

After trying to debug things, we were able to narrow it down to the protoc.exe file specifically. If he ran executable directly from cmd/powershell/bash on windows it would complain about various missing dlls. After jumping through hoops to install lots of distributables from MS, and still having no luck, we ended up downgrading the package as noted above and it is working for him.

Prior to downgrading him, we compared hashes of his and my binaries and both were the same (as you'd expect), and after downgrading was then different (also expcted).

I suspect that his windows environment is just missing some libs that mine has, but as it stands for now he isn't able to run [email protected] like the rest of the team and is having to use [email protected] instead.

is-jonreeves avatar Feb 09 '23 21:02 is-jonreeves

Looks like the cause of this is missing STDC DLLs that must have had some change to how they're packaged with the most recent release.

You can fix this by install the Visual Studio 2022 VCTools workload or potentially with a Visual C++ redistributable but I at least know the following works.

With choco you can run:

choco install visualstudio2022-workload-vctools --package-parameters "--includeRecommended"

yinzara avatar May 05 '23 20:05 yinzara

I found you need to have these two components installed on Visual Studio Build Tools 2022:

  • MSVC v143 - VS 2022 C++ x64/x86 build tools (latest)
  • Windows Universal CRT SDK

The first one is obvious, but without the second component, grpc-tools >=1.12.0 won't work on Windows.

JoseLion avatar Oct 09 '23 00:10 JoseLion