Skip to content
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

Setting CACHE_MEMORY_MAX env var crashes app #774

Open
abid-mujtaba opened this issue Oct 20, 2024 · 0 comments
Open

Setting CACHE_MEMORY_MAX env var crashes app #774

abid-mujtaba opened this issue Oct 20, 2024 · 0 comments

Comments

@abid-mujtaba
Copy link
Contributor

I set the CACHE_MEMORY_MAX env var to 2000 and on application startup I got:

/mergeable/node_modules/lru-cache/index.js:36
      throw new TypeError('max must be a non-negative number')
            ^

TypeError: max must be a non-negative number
    at new LRUCache (/mergeable/node_modules/lru-cache/index.js:36:13)
    at memoryStore (/mergeable/node_modules/cache-manager/lib/stores/memory.js:43:20)
    at Object.create (/mergeable/node_modules/cache-manager/lib/stores/memory.js:235:16)
    at Object.caching (/mergeable/node_modules/cache-manager/lib/caching.js:32:47)
    at new Cache (/mergeable/lib/cache/cache.js:22:35)
    at Object.<anonymous> (/mergeable/lib/configuration/configuration.js:8:22)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)

Looks like this can be fixed by parsing the env var as an int using something like:

function getMemoryMax () {
  return process.env.CACHE_MEMORY_MAX ? parseInt(process.env.CACHE_MEMORY_MAX) : undefined
}

Happy to open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant