GRPC client interceptor does not get called
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current behavior
GRPC client interceptor not called when passed through ClientsModule
options but is working when passed through options.channelOptions
:
This does not work:
ClientsModule.register([
{
name: 'HERO_PACKAGE',
transport: Transport.GRPC,
options: {
package: 'hero',
protoPath: join(__dirname, 'hero.proto'),
interceptors: [
(options, nextCall) => {
console.log('CALLED INTERCEPTOR');
return new InterceptingCall(nextCall(options));
},
],
},
},
])
This is working:
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));
},
],
},
},
},
])
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
- I don’t know. Or some 3rd-party 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 (see below)
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?
- macOS
- Windows
- Linux
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Yeah, it turns out #8231 was an invalid PR that exposed
interceptors
option in the wrong place. You should passinterceptors
as part of thechannelOptions
object, as in this example:#8231 will be reverted
We can use it with type casting as a workaround.
We need a proper typing though…