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 I lazy loading and resolve module/provider with transient provider and some singleton sub providers. The first exec function (API call) it works fine. But the second exec of itself, the injected providers (in this case is "B") is undefined.
When I tried to cache the result of .load() and reuse it. It works, but I'm not sure if there is a issue behind the screen that I'd have not known it yet.
By the way, in repro, the /work route is identical to the /not-work route. Therefore, you can work with any of them. The first request is successful, the second - unsuccessful.
this seems to be a bug with lazyModuleLoader#load when the module is resolved already (cached) because it works as expected when lazyModuleLoader#load returns a new instance every time
Is there an existing issue for this?
Current behavior
When I lazy loading and resolve module/provider with transient provider and some singleton sub providers. The first exec function (API call) it works fine. But the second exec of itself, the injected providers (in this case is "B") is undefined.
When I tried to cache the result of
.load()
and reuse it. It works, but I'm not sure if there is a issue behind the screen that I'd have not known it yet.Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-nzzyej?file=src%2Fapp.controller.ts
Steps to reproduce
Not-working endpoint:
/not-work
Working endpoint:
/work
Expected behavior
I expect that when using resolve, it creates a transient provider as my use case and all sub-dependencies as "Singleton" won't be re-created
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
No response
Packages versions
@nestjs/core: 10.3.0
Node.js version
20.10.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: