grpc_tools_node_protoc_ts icon indicating copy to clipboard operation
grpc_tools_node_protoc_ts copied to clipboard

protoc-gen-ts does not end process in powershell

Open ihl396 opened this issue 4 years ago • 3 comments

Summary

The grpc generators creates all the grpc js/ts artifacts in < 2 seconds, but it doesn't end the powershell script execution which can be problematic when it's chained with other npm commands.

Current Versions:

"grpc": "^1.24.3"
"grpc-tools": "^1.9.1"
"grpc_tools_node_protoc_ts": "^5.0.1"

Repro steps:

  1. Create a grpc typescript project npm install grpc_tools_node_protoc_ts --save-dev
  2. Create a ./proto directory, use a sample .proto file: https://github.com/blokur/grpc-ts-demo/blob/master/proto/songs.proto
  3. Use this script to generate the proto files:
param (
  [Parameter(Mandatory=$true)][string]$basedir
)
Push-Location $basedir
$FullPath=$PWD

$PROTOGEN_DIR="./src/protogen"
mkdir -force $PROTOGEN_DIR

$PROTOC_GEN_TS_PATH="node_modules/.bin/protoc-gen-ts.cmd"
$GRPC_TOOLS_NODE_PROTOC_PLUGIN="node_modules/.bin/grpc_tools_node_protoc_plugin.cmd"

./node_modules/.bin/grpc_tools_node_protoc `
  --js_out=import_style=commonjs,binary:"$PROTOGEN_DIR" `
  --ts_out="$PROTOGEN_DIR" `
  --grpc_out="$PROTOGEN_DIR" `
  --plugin=protoc-gen-grpc="$FullPath/$GRPC_TOOLS_NODE_PROTOC_PLUGIN" `
  -I ./proto `
  ./proto/*.proto

# TypeScript code generation
./node_modules/.bin/protoc-gen-ts `
  --plugin=protoc-gen-ts="$FullPath/$PROTOC_GEN_TS_PATH" `
  --ts_out="$PROTOGEN_DIR" `
  -I ./proto
  ./proto/*.proto

Pop-Location

Command: build-protos.ps1 -basedir .\<project root> 4. Powershell does not end process after protoc-gen-ts

ihl396 avatar Oct 21 '20 05:10 ihl396

Hi @ihl396 ,

I have no windows PC, so it's difficult for me to debug the issue of PowerShell. I would leave this issue open to see is there anybody else could solve your issue.

agreatfool avatar Oct 21 '20 06:10 agreatfool

@agreatfool powershell has been cross-platform for a while now: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1

favna avatar Apr 23 '21 20:04 favna

Oh, good to know

agreatfool avatar Apr 24 '21 07:04 agreatfool