Title: Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false · Issue #313 · node-cache/node-cache · GitHub
Open Graph Title: Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false · Issue #313 · node-cache/node-cache
X Title: Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false · Issue #313 · node-cache/node-cache
Description: Hi This is a specific case when deleteOnExpire:false and try to use has/get function in .on("expired", (key,value) => callback) Here is a small sample code to test the behaviour import NodeCache from 'node-cache'; const myCache = new Nod...
Open Graph Description: Hi This is a specific case when deleteOnExpire:false and try to use has/get function in .on("expired", (key,value) => callback) Here is a small sample code to test the behaviour import NodeCache fr...
X Description: Hi This is a specific case when deleteOnExpire:false and try to use has/get function in .on("expired", (key,value) => callback) Here is a small sample code to test the behaviour import...
Opengraph URL: https://github.com/node-cache/node-cache/issues/313
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false","articleBody":"Hi\r\n\r\nThis is a specific case when deleteOnExpire:false and try to use has/get function in .on(\"expired\", (key,value) =\u003e callback)\r\n\r\nHere is a small sample code to test the behaviour\r\n\r\n```\r\nimport NodeCache from 'node-cache';\r\n\r\nconst myCache = new NodeCache({checkperiod:10,deleteOnExpire:false});\r\nmyCache.on( \"set\", ( key, value ) =\u003e console.log(\"On SET \"+ key + '=' + value));\r\nmyCache.on( \"del\", ( key, value ) =\u003e console.log(\"On DEL: \"+ key + '=' + value));\r\nmyCache.on( \"expired\", ( key, value ) =\u003e {\r\n console.log(\"On EXPIRED \"+ key + '=' + value);\r\n //myCache.set(key, value+'_',10); // \u003c-- Uncommenting will work, commenting this line will crash process due to either of below lines causing recursion \r\n let test1 = myCache.has(key); //\u003c--\r\n let test2 =myCache.get(key); // \u003c-- \r\n});\r\n\r\nmyCache.set(\"MyKey\",\"MyValue\",5);\r\n\r\n//Below code is dummy/sample long running code.... \r\nlet done =1;\r\n(function wait () {\r\n if (done) setTimeout(wait, 1000);\r\n})();\r\n\r\n```\r\n\r\n─$ node test.mjs\r\nOn EXPIRED MyKey=MyValue\r\nOn EXPIRED MyKey=MyValue\r\nOn EXPIRED MyKey=MyValue\r\n.... \r\nOn EXPIRED MyKey=MyValue\r\nnode:internal/console/constructor:309\r\n if (isStackOverflowError(e))\r\n ^\r\n\r\nRangeError: Maximum call stack size exceeded\r\n at console.value (node:internal/console/constructor:309:13)\r\n at console.log (node:internal/console/constructor:380:26)\r\n at NodeCache.\u003canonymous\u003e (file:///Users/raxitsmacbook/MyNodeRnd/test.mjs:7:10)\r\n at NodeCache.emit (node:events:514:28)\r\n at NodeCache._check (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:659:16)\r\n at NodeCache.has (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:575:52)\r\n at NodeCache.\u003canonymous\u003e (file:///Users/raxitsmacbook/MyNodeRnd/test.mjs:9:22)\r\n at NodeCache.emit (node:events:514:28)\r\n at NodeCache._check (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:659:16)\r\n at NodeCache.has (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:575:52)\r\n\r\nNode.js v18.17.1 (However it looks like this behaviour is independent of Node version, Just in case if version can be of any help.)\r\n\r\nPossible bug also in: mget when deleteOnExpire:false\r\n\r\nAlso when deleteOnExpire:false it constantly emits \"expired\" event on every 'checkperiod' times. (But it does not crash, But nice to have non-periodic expire event unless the object/key/value/expiry etc has been modified.","author":{"url":"https://github.com/raxitsheth","@type":"Person","name":"raxitsheth"},"datePublished":"2023-09-06T18:50:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/313/node-cache/issues/313"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:48d9ce81-649f-2752-cfa3-e1ba54e74c99 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E2E:DF47A:EC70C0E:1340BCDA:69772E89 |
| html-safe-nonce | 0ef76dc7e74697d5b545217c13ffe0a3737c1ed5947d8fac270f7496f25dc3d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTJFOkRGNDdBOkVDNzBDMEU6MTM0MEJDREE6Njk3NzJFODkiLCJ2aXNpdG9yX2lkIjoiMjk3NjM0MjU3OTAzODU5Njc0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6fd2006e36bcc96a01c6af8cdb254d184f9ea7db89d5f6ed532ee2781ddb5cd6 |
| hovercard-subject-tag | issue:1884571265 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/node-cache/node-cache/313/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2ec034a3b8928d7eba29079b186ac68b7a5d383f7d26fae9abe381b94f8581ea/node-cache/node-cache/issues/313 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2ec034a3b8928d7eba29079b186ac68b7a5d383f7d26fae9abe381b94f8581ea/node-cache/node-cache/issues/313 |
| og:image:alt | Hi This is a specific case when deleteOnExpire:false and try to use has/get function in .on("expired", (key,value) => callback) Here is a small sample code to test the behaviour import NodeCache fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | raxitsheth |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/node-cache/node-cache git https://github.com/node-cache/node-cache.git |
| octolytics-dimension-user_id | 54621913 |
| octolytics-dimension-user_login | node-cache |
| octolytics-dimension-repository_id | 2599450 |
| octolytics-dimension-repository_nwo | node-cache/node-cache |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 2599450 |
| octolytics-dimension-repository_network_root_nwo | node-cache/node-cache |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f752335dbbea672610081196a1998e39aec5e14b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width