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
But injecting those same providers through the constructor, the DI resolves all providers perfectly
This does work:
@Injectable()classTestTargetService{
@Inject(SYMBOL_INJECTOR)privatereadonly[SYMBOL_SERVICE]: SymbolService;constructor(privatereadonlytestService: TestService){}getTestService(){returnthis.testService;}getSymbolService(){returnthis[SYMBOL_SERVICE];// Symbol Service Instance}}
I've spent a time debugging and found something about the cache of the metadatas. The property's instance wrapper was a new property but it was supposed to be an element inside the array, increasing its length. Was it supposed to be added as a new property?
Is there an existing issue for this?
Current behavior
The DI isn't injecting/resolving a provider through @Inject when the property is a Symbol
This doesn't work:
But injecting those same providers through the constructor, the DI resolves all providers perfectly
This does work:
I've spent a time debugging and found something about the cache of the metadatas. The property's instance wrapper was a new property but it was supposed to be an element inside the array, increasing its length. Was it supposed to be added as a new property?
Minimum reproduction code
https://github.com/BrendonMFO/nestjs-injection-bug
Steps to reproduce
npm i
npm test
There're two test files each one using a different way to inject the providers
Expected behavior
The DI should be able to resolve the dependencies through constructor and the decorator
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
8.4.1
Packages versions
Node.js version
16.13.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: