Closed sjkummer closed 3 years ago
The inheritAppConfig
is expected, and is documented here. If that alone doesn't fix it, please provide a minimum reproduction
Thanks for that doc link 🙌
I confirm, setting inheritAppConfig
is sufficient in a clean setup.
Bug Report
Current behavior
Global interceptors are not called for GRPC methods (probably the same for all RPC methods).
Input Code
I added the
logging.interceptor.ts
example from https://docs.nestjs.com/interceptors#aspect-interception tosample/04-grpc
of this repo.Current behavior
The logging interceptor is executed, if I call the REST method e.g. http://localhost:3001/hero/1 but NOT if I call the GRPC method.
Expected behavior
Interceptors should be executed in all contexts.
Possible Solution
I can get the global GRPC interceptor working by doing two things (both must be done, otherwise it's not working):
Changing the
rpc-context-creator.js
as follows: Line L124ff: https://github.com/nestjs/nest/blob/master/packages/microservices/context/rpc-context-creator.ts#L124Background: The interceptors are only set in
create()
... but they are empty at this time - althoughuseGlobalInterceptors
is called directly afterNestFactory.create()
Calling
connectMicroservice
withinheritAppConfig
This shouldn't e required right? But if yes, then it should be documented.
Environment