You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
TypeError: Cannot read properties of undefined (reading 'get')
at DiscoverableMetaHostCollection.getProvidersByMetaKey (/home/projects/nestjs-typescript-starter-9qt4jp/node_modules/@nestjs/core/discovery/discoverable-meta-host-collection.js:46:34)
at DiscoveryService.getProviders (/home/projects/nestjs-typescript-starter-9qt4jp/node_modules/@nestjs/core/discovery/discovery-service.js:42:98)
at AppTestModule.onModuleInit (/home/projects/nestjs-typescript-starter-9qt4jp/dist/main.js:38:49)
at callModuleInitHook (/home/projects/nestjs-typescript-starter-9qt4jp/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:35)
at async NestApplication.callInitHook (/home/projects/nestjs-typescript-starter-9qt4jp/node_modules/@nestjs/core/nest-application-context.js:223:13)
at async NestApplication.init (/home/projects/nestjs-typescript-starter-9qt4jp/node_modules/@nestjs/core/nest-application.js:100:9)
at async bootstrap (/home/projects/nestjs-typescript-starter-9qt4jp/dist/main.js:55:5)
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.
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: