@nestjs/microservices
can't handle gRPC package versioning.
#13719
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
As shown in this document, gRPC allows version control by including the version number in the "package".
https://learn.microsoft.com/en-us/aspnet/core/grpc/versioning?view=aspnetcore-3.1#version-number-services
Normally, each implementation should be called according to the requested version.
However, in "@nestjs/microservices", the wrong handler is invoked when a gRPC package with a different version is registered.
Minimum reproduction code
https://github.com/mishio-n/nest-grpc-multi-versioning/
controller for
v1
controller for
v2
Steps to reproduce
I'm using Buf CLI for gRPC request.
pnpm start:dev
hello.v1.HelloService/Version
Since the request is for v1, "v1" is expected to be returned.
https://github.com/mishio-n/nest-grpc-multi-versioning/blob/main/src/hello/v1/hello.v1.controller.ts#L21
Expected behavior
After checking the source code of "@nestjs/microservices", I believe this behavior is caused by the following code.
https://github.com/nestjs/nest/blob/master/packages/microservices/server/server-grpc.ts#L447-L455
Here, "route" contains the following information.
The information comes from the "@GrpcMethod" decorator, and I see no way to include the package name here.
So, implementations between different packages will be registered overwriting.
nest/packages/microservices/decorators/message-pattern.decorator.ts
Lines 101 to 103 in 15cb568
I may be mistaken, though,
How can I handle versioning?
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
10.0.0
Packages versions
Node.js version
20.11.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: