Closed micalevisk closed 5 months ago
I'm not sure if this is related to NestJS tbh - this doesn't sound like a pattern we'd like to support at the framework level. My hunch is that your process crashes because you're entering a circular loop that never exists and runtime seeing that just terminates it, but I might be wrong - I'd have to spend more time looking into this
I'd like this to work because I'm trying to conditionally loading a module depending on a provider's value, which is why I need to use factory providers
This doesn't sound like something you should be doing. If you want to load a module dynamically, use lazy modules. Otherwise, the modules graph is constructed before providers are resolved so this won't ever work without magic tricks that your app shouldn't rely on
Is there an existing issue for this?
Current behavior
I found that it is getting stuck at
await metatype
bellow in this case. I've no clue on why is this nor if this is the expected behavior due to some limitation.https://github.com/nestjs/nest/blob/9b1efbc823f01737ed0abe0291632db18272e646/packages/core/injector/compiler.ts#L17-L20
I'd like this to work because I'm trying to conditionally loading a module depending on a provider's value, which is why I need to use factory providers
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-nwqhob?file=src%2Fapp.module.ts
Steps to reproduce
npm i
on their terminalnpm start
on their terminal and see that the process just crash right awayExpected behavior
I expect it to work just like it works when using a value provider instead of a factory provider. So I should see the following output:
Or, if this is limitation, we should at least see some error (if there's any) instead of stopping the process silently
Package
Other package
No response
NestJS version
10.3.9
Packages versions
Node.js version
No response
In which operating systems have you tested?
Other
No response