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
I have a helper function that creates the CacheModule dynamically based on some input. This function is called multiple times for different modules that rely on CacheModule.
The CacheModule however is not loading the settings correctly. Only one of the settings set are loaded and applied to all other modules using the same function.
in the second screenshot you can see that only the useFactory of AModule gets called and BModule gets the same config from AModule even though they are created differently.
I expected the ttl and all other settings to be different for in BModule, but insteead BModule got the same settings from AModule (see screenshots above)
Package version
2.1.1
NestJS version
10.2.8
Node.js version
21.1.0
In which operating systems have you tested?
macOS
Windows
Linux
Other
No response
The text was updated successfully, but these errors were encountered:
I also ran into this. But after upgrading from 10.2.10 --> @nestjs/common@10.3.0 and @nestjs/core@10.3.0. In thisprovided repo the tests fail , there is also a working branch.
After investigation, I realized that the useFactory function provided by CACHE_MANAGER is only called when the options parameter is registered differently.
Is there any caching mechanism applied when initializing a dynamic provider here related to ConfigurableModuleBuilder? If so, I think we can fix this issue by generating a unique ID each time the CacheModule is registered, like the following:
Is there an existing issue for this?
Current behavior
I have a helper function that creates the CacheModule dynamically based on some input. This function is called multiple times for different modules that rely on CacheModule.
The CacheModule however is not loading the settings correctly. Only one of the settings set are loaded and applied to all other modules using the same function.
function:
expected logs:
current logs:
in the second screenshot you can see that only the
useFactory
of AModule gets called and BModule gets the same config from AModule even though they are created differently.Minimum reproduction code
https://github.com/GustavoKatel/nestjs-cache-module-test
Steps to reproduce
npm ci
npm run start
Expected behavior
I expected the ttl and all other settings to be different for in BModule, but insteead BModule got the same settings from AModule (see screenshots above)
Package version
2.1.1
NestJS version
10.2.8
Node.js version
21.1.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: