You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i get an error when generating typescript types with a proto file that works normally with loadSync and older grpc.load. is this the right place to post this? the stack trace says the error occurred in protobufjs
# not js, this is shell script# download LND proto file
wget -O lightning.proto https://raw.githubusercontent.com/lightningnetwork/lnd/b208642caf96b5753e9e295450a26917e1b0bb0b/lnrpc/lightning.proto
# try generate typescript types
npx proto-loader-gen-types --keepCase --longs=String --enums=String --defaults --oneofs --grpcLib=@grpc/grpc-js --outDir=types lightning.proto
(proto-loader-gen-types is from @grpc/proto-loader)
Error: illegal token 'PendingChannels' (lightning.proto, line 153)
at illegal (/tmp/node_modules/protobufjs/src/parse.js:96:16)
at parseService_block (/tmp/node_modules/protobufjs/src/parse.js:699:23)
at ifBlock (/tmp/node_modules/protobufjs/src/parse.js:290:17)
at parseService (/tmp/node_modules/protobufjs/src/parse.js:691:9)
at parseCommon (/tmp/node_modules/protobufjs/src/parse.js:269:17)
at parse (/tmp/node_modules/protobufjs/src/parse.js:829:21)
at process (/tmp/node_modules/protobufjs/src/root.js:127:30)
at /tmp/node_modules/protobufjs/src/root.js:194:17
at fetchReadFileCallback (/tmp/node_modules/@protobufjs/fetch/index.js:51:19)
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
i noticed (and use this as a workaround now) that removing all // comments makes it work:
sed -Ei '/^ +\/\/.*/d' lightning.proto
The text was updated successfully, but these errors were encountered:
> root.loadSync('lightning.proto', {alternateCommentMode: true})
Uncaught Error: illegal token 'PendingChannels' (lightning.proto, line 153)
at illegal (/private/tmp/lightning/node_modules/protobufjs/src/parse.js:96:16)
at parseService_block (/private/tmp/lightning/node_modules/protobufjs/src/parse.js:699:23)
at ifBlock (/private/tmp/lightning/node_modules/protobufjs/src/parse.js:290:17)
at parseService (/private/tmp/lightning/node_modules/protobufjs/src/parse.js:691:9)
at parseCommon (/private/tmp/lightning/node_modules/protobufjs/src/parse.js:269:17)
at parse (/private/tmp/lightning/node_modules/protobufjs/src/parse.js:829:21)
at process (/private/tmp/lightning/node_modules/protobufjs/src/root.js:127:30)
at fetch (/private/tmp/lightning/node_modules/protobufjs/src/root.js:178:13)
at Root.load (/private/tmp/lightning/node_modules/protobufjs/src/root.js:206:13)
at Root.loadSync (/private/tmp/lightning/node_modules/protobufjs/src/root.js:247:17)
So this is caused by alternateCommentMode being enabled by @grpc/proto-loader. Your proto file has a mix of // and /* ... */ comments, which apparently confuses the parser. I won't be able to look into this deeper soon enough, but should you have a fix, please feel free to contribute :)
protobuf.js version: 7.1.0
i get an error when generating typescript types with a proto file that works normally with loadSync and older grpc.load. is this the right place to post this? the stack trace says the error occurred in protobufjs
(
proto-loader-gen-types
is from@grpc/proto-loader
)i noticed (and use this as a workaround now) that removing all
//
comments makes it work:sed -Ei '/^ +\/\/.*/d' lightning.proto
The text was updated successfully, but these errors were encountered: