DiscoveryService's getProviders and getControllers fail when metadata key is not applied at least once #12518
Closed
4 of 15 tasks
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
When using getProvider/getControllers with
metadataKey
parameter and there is no use of this metadata, i.e. decorator is not applied to any class, -- both methods fail due to wrappersByMetaKey being undefined.Error:
Not sure if this is intended, as they're supposed to behave like filters and could just return an empty array when there are no suitable providers/controllers.
Minimum reproduction code
https://stackblitz.com/edit/nestjs-discovery-service-issue?file=src%2Fmain.ts
Steps to reproduce
npm i
npm run start
Then bring back
@DiscoverDecorator
on controller and provider - it will work.Expected behavior
These methods could return
[]
instead.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.2.0+
Packages versions
Node.js version
18.18.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: