-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CacheModule in multiple modules not loading the config properly #203
Comments
I also ran into this. But after upgrading from 10.2.10 --> @nestjs/[email protected] and @nestjs/[email protected]. |
While testing with the following versions:
the issue seems resolved, but a strange bug occurs when After investigation, I realized that the cache-manager/lib/cache.providers.ts Line 19 in 65d7101
Is there any caching mechanism applied when initializing a dynamic provider here related to static register<StoreConfig extends Record<any, any> = Record<string, any>>(
options: CacheModuleOptions<StoreConfig> = {} as any,
): DynamicModule {
return {
global: options.isGlobal,
...super.register({ ...options, id: <UNIQUE_ID> }),
};
} |
Fixed in this PR nestjs/nest#13336 |
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: