mistval / node-fetch-cache

Node-fetch with built-in response caching.
MIT License
51 stars 8 forks source link

Error with circular reference of a http agent on the fetch options #10

Closed PhilHannent closed 3 years ago

PhilHannent commented 3 years ago

We are using the library agentkeepalive to reduce the number of outbound connections. I also am testing adding this library but have been getting an error:

TypeError: Converting circular structure to JSON\n --> starting at object with constructor 'TLSSocket'\n | property 'parser' -> object with constructor 'HTTPParser'\n --- property 'socket' closes the circle\n at JSON.stringify (<anonymous>)\n at getCacheKey

The use of the Agent is breaking a JSON.stringify() on this line:

return md5(JSON.stringify([resourceCacheKeyJson, initCacheKeyJson, CACHE_VERSION]));

mistval commented 3 years ago

Hi, this should now be fixed in v2.0.1 by 524308aa61d967a29f93c82acb32c35c7fd6d50e, please try again with the new version and let me know if you still face any issue.