DevPortal

Interval timer bug

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #281
    Loom Kish
    Participant

    Hey there,

    I’ve IM’d this as well, but thought I’d drop a line here.

    I think I’ve found a bug in your timer code. See the below script it starts an interval timer that runs 10 times, then clears it. if you click the stop button before it clears, it keeps running. I can stop and restart and see the old copy still running with two counters. I assume this means that any scripts with timers that run indefinitely will never finish – leading to some kind of resource starvation – particularly prevalent during development when trial and error or find/fix debugging kicks in.

    console.log("timer test");
    
    var count = 10;
    
    var timer = setInterval( function (){
    	
    	console.log( count + "." );
    	count--;
    	
    	if( count == 0 )
    		clearInterval( timer );
    	
    }, 3000 );
    
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.