Open thnam1410 opened 3 months ago
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
Other package
No response
NestJS version
No response
Packages versions
Node.js version
20.10.0
In which operating systems have you tested?
Other
No response