Closed ZanzyTHEbar closed 2 months ago
Hi @ZanzyTHEbar, it looks like you may be using Protobuf-ES v2.0 with Connect-ES v1.4.0. The 1.x versions of Connect-ES are not compatible with Protobuf-ES v2.0.
Since you are using local plugins, can you verify the version of @bufbuild/protobuf
that you have in your package.json file? You should be able to fix it by pinning your version of that to ^1.10.0
. Try that and let me know if it fixes your issue.
I will do so. Will have to wait a few hours though, 12am for me atm ;)
Will let you know.
Thanks for the prompt response :)
Correct me if i am wrong, but isnt the newest version of connect-es
at 1.4.0
- is there an intentional reason with Protobuf-es
version incompatibility? Would be great if that was clearer in the documentation as well. For example, why v1.10.0? Is that the latest compatible version, or is there something special about it?
Anywho, will get back to you shortly.
I have tried your suggestion
pnpm i @bufbuild/protoc-gen-es@^1.10.0 @bufbuild/buf@^1.39.0 @bufbuild/protobuf@^2.0.0 @connectrpc/protoc-gen-connect-es@^1.4.0
However, when i try to build my proto files i receive this error:
❯ make proto
Generating proto files using buf cli ...
Linting passed. Proceeding to generate code ...
protoc-gen-es: Cannot read properties of undefined (reading 'BIGINT')
Failure: plugin protoc-gen-es: exit status 1
make: *** [Makefile:63: proto] Error 1
I have changed nothing else about my proto file.
If i update my protobuf-es
to 2.0.0, i solve the BIGINT
issue and my proto files build fine, I get my types. However, due to having a protobuf: ^1.10.0
i now get this error upon pnpm build
:
error during build:
[commonjs--resolver] Missing "./codegenv1" specifier in "@bufbuild/protobuf" package
For reference - here is my tsconfig.json
You also need @bufbuild/protobuf
at 1.10.0 also:
pnpm i @bufbuild/protoc-gen-es@^1.10.0 @bufbuild/buf@^1.39.0 @bufbuild/protobuf@^1.10.0 @connectrpc/protoc-gen-connect-es@^1.4.0
Okay, i uninstalled everything, pruned my cache, reinstalled everything.
✓ 143 modules transformed.
x Build failed in 326ms
error during build:
Could not resolve "./gen/status_pb.js" from "node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/trailer-status.js"
file: /mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/trailer-status.js
at getRollupError (file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
at error (file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
at ModuleLoader.handleInvalidResolvedId (file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/node-entry.js:19255:24)
at file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/node-entry.js:19215:26
ELIFECYCLE Command failed with exit code 1.
The correct versions are being used - but it is still not able to build. Seems its looking in the wrong directory?
I apologize if this is not relevant to connect-es
specifically or is a user error. I am just genuinely confused on what i could be doing wrong.
I have updated my project to the syntax required, and everything in my intellisense resolves correctly. However, now i have this final error:
> vite build
vite v5.4.3 building for production...
✓ 143 modules transformed.
x Build failed in 320ms
error during build:
Could not resolve "./gen/status_pb.js" from "node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/trailer-status.js"
file: /mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/trailer-status.js
at getRollupError (file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
at error (file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
at ModuleLoader.handleInvalidResolvedId (file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/node-entry.js:19255:24)
at file:///mnt/data/Projects/Personal/OpenSource/goflexpro/frontend/node_modules/.pnpm/rollup@4.21.2/node_modules/rollup/dist/es/shared/node-entry.js:19215:26
ELIFECYCLE Command failed with exit code 1.
I have checked the installed version of @connectrpc/connect
- and there is indeed no gen
folder in the dist
directory. Not in esm
or cjs
. I am, of course, using esm for this project.
I found the file on the github: https://github.com/connectrpc/connect-es/tree/main/packages/connect/src/protocol-grpc/gen
However, i do not seem to have this directory at all
I have no idea what i did - but i cleaned my cache again, removed my node_modules, etc, totally clean project and tried again ... and now everything works. I am totally confused. I would like to understand it. But .. for now .. i can say that the problem is "fixed".
Strange. Yeah, just to clarify things here:
Connect-ES is currently at v1.4.0
, which is only compatible with v1.x versions of the following:
There is a v2 version of the above @bufbuild
packages, but Connect-ES is not currently compatible with v2. So, if you are using Connect-ES with Protobuf-ES, you have to stick with v1.x versions of everything. For @bufbuild
packages, the latest version is v1.10.0
.
I'm not sure how your local deps got into that state, but there are corner cases where this could happen. Fwiw, when generating code, we recommend installing using the instructions here
Strange. Yeah, just to clarify things here:
Connect-ES is currently at
v1.4.0
, which is only compatible with v1.x versions of the following:
- @bufbuild/protobuf
- @bufbuild/protoplugin
- @bufbuild/protoc-gen-es
There is a v2 version of the above
@bufbuild
packages, but Connect-ES is not currently compatible with v2. So, if you are using Connect-ES with Protobuf-ES, you have to stick with v1.x versions of everything. For@bufbuild
packages, the latest version isv1.10.0
.I'm not sure how your local deps got into that state, but there are corner cases where this could happen. Fwiw, when generating code, we recommend installing using the instructions here
This is indeed the instructions i followed. I used @latest
at the end of all the install, however.
Gotcha. Yeah, @latest
would cause this. We updated those docs to pin to the correct versions about a month ago. So, hopefully, it clears up confusion.
Going to close this PR, but if you notice anything else amiss, feel free to open another issue.
Describe the bug
crearePromiseClient
returns aPromise<unknown>
.Which doesn't make sense, as that should be passed down via the generic.
product_connect.ts
file has multiple errors:Module '"@bufbuild/protobuf"' has no exported member 'MethodKind'.
All
I
andO
members have a'X' only refers to a type, but is being used as a value here.
To Reproduce
Install the deps, spin up a base-bones project based on the example using the newest version of the protoc plugin.
Environment (please complete the following information):
If your problem is specific to bundling, please also provide the following information:
Additional context Here are my relevant files:
lint: use:
package product.v1;
option go_package = "github.com/ZanzyTHEbar/goflexpro/pkgs/gen/product/v1";
message ProductDTO { int32 id = 1; string name = 2; string description = 3; double price = 4; string created_at = 5; }
message CreateProductRequest { repeated ProductDTO product = 1; }
message CreateProductResponse { repeated bool success = 1; }
message GetProductRequest { repeated int32 id = 1; }
message GetProductResponse { repeated ProductDTO product = 1; }
message UpdateProductRequest { repeated ProductDTO product = 1; }
message UpdateProductResponse { repeated bool success = 1; }
message DeleteProductRequest { repeated int32 id = 1; }
message DeleteProductResponse { repeated bool success = 1; }
service ProductService { rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse); rpc GetProduct(GetProductRequest) returns (GetProductResponse); rpc UpdateProduct(UpdateProductRequest) returns (UpdateProductResponse); rpc DeleteProduct(DeleteProductRequest) returns (DeleteProductResponse); }