GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false · Issue #313 · node-cache/node-cache

Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false #313

New issue
Copy link
New issue
Copy link
Open
Open
Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false#313
Copy link

Description

@raxitsheth
raxitsheth
opened on Sep 6, 2023
Issue body actions

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 NodeCache({checkperiod:10,deleteOnExpire:false});
myCache.on( "set", ( key, value ) => console.log("On SET "+ key + '=' + value));
myCache.on( "del", ( key, value ) => console.log("On DEL: "+ key + '=' + value));
myCache.on( "expired", ( key, value ) => {
        console.log("On EXPIRED "+ key + '=' + value);
        //myCache.set(key, value+'_',10); // <-- Uncommenting will work, commenting this line will crash process due to either of below lines causing recursion 
        let test1 = myCache.has(key); //<--
        let test2 =myCache.get(key); // <-- 
});

myCache.set("MyKey","MyValue",5);

//Below code is dummy/sample long running code.... 
let done =1;
(function wait () {
   if (done) setTimeout(wait, 1000);
})();

─$ node test.mjs
On EXPIRED MyKey=MyValue
On EXPIRED MyKey=MyValue
On EXPIRED MyKey=MyValue
....
On EXPIRED MyKey=MyValue
node:internal/console/constructor:309
if (isStackOverflowError(e))
^

RangeError: Maximum call stack size exceeded
at console.value (node:internal/console/constructor:309:13)
at console.log (node:internal/console/constructor:380:26)
at NodeCache. (file:///Users/raxitsmacbook/MyNodeRnd/test.mjs:7:10)
at NodeCache.emit (node:events:514:28)
at NodeCache._check (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:659:16)
at NodeCache.has (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:575:52)
at NodeCache. (file:///Users/raxitsmacbook/MyNodeRnd/test.mjs:9:22)
at NodeCache.emit (node:events:514:28)
at NodeCache._check (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:659:16)
at NodeCache.has (/Users/raxitsmacbook/MyNodeRnd/node_modules/node-cache/lib/node_cache.js:575:52)

Node.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.)

Possible bug also in: mget when deleteOnExpire:false

Also 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.

Activity

  1. raxitsheth
    changed the title [-]Recursive call: RangeError: Maximum call stack size exceeded - deleteOnExpire:false[/-] [+]Recursive call: RangeError: Maximum call stack size exceeded when deleteOnExpire:false[/+] on Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.