-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 client interceptor does not get called #9079
Comments
I had the exact same issue. Does anyone know how to solve this? |
This error happen because interceptors option not pass to grpc-js client https://github.com/nestjs/nest/blob/master/packages/microservices/client/client-grpc.ts#L65 |
It's so weird, we already have an PR to expose interceptors option for gRPC but it doesn't get passed to grpc-js client? |
Yeah, it turns out #8231 was an invalid PR that exposed ClientsModule.register([
{
name: 'HERO_PACKAGE',
transport: Transport.GRPC,
options: {
package: 'hero',
protoPath: join(__dirname, 'hero.proto'),
channelOptions: {
interceptors: [
(options, nextCall) => {
console.log('CALLED INTERCEPTOR');
return new InterceptingCall(nextCall(options));
},
],
},
},
},
]) #8231 will be reverted |
@kamilmysliwiec
|
Yes, I have same problem |
We can use it with type casting as a workaround. const options = {
...
} as unknown as GrpcOptions
// or more specifically
const options = {
options: {
channelOptions: {
interceptors: [SomeInterceptor],
} as unknown as GrpcOptions['options']['channelOptions']
}
} We need a proper typing though... |
Let's track this here #9587 |
Is there an existing issue for this?
Current behavior
GRPC client interceptor not called when passed through
ClientsModule
options but is working when passed throughoptions.channelOptions
:This does not work:
This is working:
Minimum reproduction code
https://github.com/ckfngod/grpc-client-interceptor-issue
Steps to reproduce
npm i
npm run start
curl localhost:3000
GRPC request is successful but there is no console output from application when interceptor should be logging.
Expected behavior
GRPC client interceptor should be called.
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
8.2.6
Packages versions
[System Information]
OS Version : macOS Monterey
NodeJS Version : v16.13.2
NPM Version : 8.1.2
[Nest CLI]
Nest CLI Version : 8.2.0
[Nest Platform Information]
platform-express version : 8.2.6
microservices version : 8.2.6
schematics version : 8.0.5
testing version : 8.2.6
common version : 8.2.6
core version : 8.2.6
cli version : 8.2.0
Node.js version
16.13.2
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: