Timers: setInterval stops executing the callback

28 views
Skip to first unread message

Emilio

unread,
Jun 9, 2014, 4:18:01 PM6/9/14
to nod...@googlegroups.com
Hi, I'm having some trouble figuring out whats going on with a timer that I setup with this code:

var cronTasksTimer = setInterval(__.bind(gameServer.runCronTasks, gameServer), 1000 * 10);

If I inspect the cronTasksTimer when the cron is working I see something like:
{ _idleTimeout: 10000,
  _idlePrev: 
   { _idleNext: [Circular],
     _idlePrev: 
      { _idleTimeout: 10000,
        _idlePrev: [Circular],
        _idleNext: [Circular],
        _idleStart: 1402343890428,
        _onTimeout: [Function],
        _repeat: false },
     msecs: 10000,
     ontimeout: [Function: listOnTimeout] },
  _idleNext: 
   { _idleTimeout: 10000,
     _idlePrev: [Circular],
     _idleNext: 
      { _idleNext: [Circular],
        _idlePrev: [Circular],
        msecs: 10000,
        ontimeout: [Function: listOnTimeout] },
     _idleStart: 1402343890428,
     _onTimeout: [Function],
     _repeat: false },
  _idleStart: 1402343898130,
  _onTimeout: [Function: wrapper],
  _repeat: true }

But sometimes the cron function stops working (the callback doesn't run anymore), when this happens I inspect  cronTasksTimer and I see this:

{ _idleTimeout: 10000,
  _idlePrev: null,
  _idleNext: null,
  _idleStart: 1402331871559,
  _onTimeout: [Function: wrapper],
  _repeat: true }

In this state I can execute the cron with:
cronTasksTimer._onTimeout(); // the function works wells.

Any help or clarification on why this could happen would be really appreciated.

My process is running node v0.10.24 on Ubuntu with kernel 3.14.4-x86_64.

Thanks!







Reply all
Reply to author
Forward
0 new messages