Closed pergerk closed 2 years ago
An ArgumentHost has never been able to get the class or handler, because ArgumentHost
is used in an ExceptionFilter where there may not be a matching class or route handler (404s and such). Only the ExecutionContext has the getClass()
and getHandler()
methods. And the ExecutionContext
is different than the host.switchToRcp().getContext()
return object.
Is there an existing issue for this?
Current behavior
Hello, I am trying to getClass and getHandler under rpc but functions are undefined? And I doing it wrong or do we have any case to solve this ?
const rpc = host.switchToRpc(); const ctx = rpc.getContext();
console.log('host.getType()', host.getType());
console.log('ctx.getClass fn', ctx.getClass);
console.log('ctx.getHandler fn', ctx.getHandler);
ctx.getClass and ctx.getHandler are undefined under rpc scope
Minimum reproduction code
https://github.com/pergerk/microservices
Steps to reproduce
npm i npm run start:dev gw & npm run start:dev service1 & npm run start:dev service2 curl http://localhost:3000/service1
Expected behavior
const ctx = rpc.getContext();
should return name of class ctx.getClass().name
should return name of handler ctx.getHandler().name
Package
Other package
No response
NestJS version
8.1.2
Packages versions
Node.js version
v16.5.0
In which operating systems have you tested?
Other
[Nest] 89073 - 31.10.2021, 05:59:43 LOG [NestMicroservice] Nest microservice successfully started +12ms callone called host.getType() rpc ctx.getClass fn undefined ctx.getHandler fn undefined filtered instance rpc Error in service 1