Skip to content

Cannot read properties of undefined (reading 'get') when using cache-manager@5.2.3 #22

Description

@alanskovrlj

Describe the bug
When using cache-manager@5.2.3 package for redis store throws the following error:
"Cannot read properties of undefined (reading 'get')"

Reproduce:

  1. npm init, run redis server
  2. npm i http-cache-middleware cache-manager-ioredis restana cache-manager@5.2.3
  3. run following code from below
  4. Send http request to one of the endpoints
const CacheManager = require('cache-manager')
const redisStore = require('cache-manager-ioredis')
const redisCache = CacheManager.caching({
  store: redisStore,
  db: 0,
  host: 'localhost',
  port: 6379,
  ttl: 30
})
const middleware = require('http-cache-middleware')({
  stores: [redisCache]
})

const service = require('restana')()
service.use(middleware)

service.get('/cache', (req, res) => {
  setTimeout(() => {
    res.setHeader('x-cache-timeout', '1 minute')
    res.send('this supposed to be a cacheable response')
  }, 50)
})

service.delete('/cache', (req, res) => {
  res.setHeader('x-cache-expire', '*/cache-*')
  res.end()
})

service.start(3000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions