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

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

Open
long1eu opened this issue Jan 26, 2023 · 5 comments
Open

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

long1eu opened this issue Jan 26, 2023 · 5 comments

Comments

@long1eu
Copy link

long1eu commented Jan 26, 2023

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

  • Windows 11, Intel
  • Node version: 16.19.0
  • Node installation method: choco
  • Package name and version: libprotoc@3.20.1, gRPC@1.12.3

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
Copy link
Author

long1eu commented Jan 31, 2023

Is there a way to debug this?

@robido
Copy link

robido commented Feb 8, 2023

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 grpc-tools@1.11.3

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?

@is-jonreeves
Copy link

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 grpc-tools@1.12.3 like the rest of the team and is having to use grpc-tools@1.11.3 instead.

@yinzara
Copy link

yinzara commented May 5, 2023

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"

@JoseLion
Copy link

JoseLion commented Oct 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants