node-cache-manager-redis icon indicating copy to clipboard operation
node-cache-manager-redis copied to clipboard

TypeError: Converting circular structure to JSON

Open moshest opened this issue 9 years ago • 1 comments

Warp data with circular structure return an error which is OK: "TypeError: Converting circular structure to JSON"

But afterwards any request to the cache will no response anything and got stuck.

const cacheManager = require( 'cache-manager');

const cache = cacheManager.caching({
  ttl: 10 * 60, // 10 minutes
  store: require('cache-manager-redis')
});

const data = { foo: 'bar' };
data.data = data; // circular structure


cache.set('key', data, (err, result) => {
  console.error(err); // TypeError: Converting circular structure to JSON

  cache.get('key', (err, res) => {
    console.log(err, res); // never called!
  });
});

moshest avatar Dec 14 '16 13:12 moshest

This is probably related to usage of JSON.stringify. We should add this as a test case and fix.

mrister avatar Aug 21 '17 08:08 mrister