# Recursive setTimeouts prevent rendering

**URL:** <https://forums.bitovi.com/t/recursive-settimeouts-prevent-rendering/189>\
**Category:** CanJS\
**Created:** [March 16, 2016, 2:53pm UTC](https://forums.bitovi.com/t/recursive-settimeouts-prevent-rendering/189 "2016-03-16T14:53:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbleier](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@dbleier](https://forums.bitovi.com/u/dbleier)\
**Post date:** [March 16, 2016, 2:53pm UTC](https://forums.bitovi.com/t/recursive-settimeouts-prevent-rendering/189/1 "2016-03-16T14:53:52Z")

</div>

I posted the following question and got the solution on gitter and am posting it here for reference.

**Issue** :  
I am recursively calling setTimeout and when I do, stache never renders. I think the reason is because can-wait overrides setTimeout with it’s own version. And then waits for it to resolve before rendering, but since it is recursive, it never finishes. How to get around this?

```auto
   loadSlide(slides, index) {
    var self = this, cs = slides[index], 
    next = (index + 1) % slides.length;
    this.attr('currentSlide', cs);
    setTimeout(function() {
      self.loadSlide.call(self, slides, next);
    }, 
      cs.props.duration * 1000
    );
  },

```

* * *

**Solution** :  
@matthewp said:

> Yeah, if you are recursively calling setTimeout you will want to ignore that  
> you can do var ignore = require(‘can-wait/ignore’)  
> which allows you to wrap some code you want to run outside of the zone

```auto
 var fn = ignore(function() { setTimeout(function{ .... } } )
fn(); // You'll get the real setTimeout

```

* * *

**Link to gitter conversation** :  
[https://gitter.im/canjs/canjs?at=56e8748f0055f8f35a837e6b](https://gitter.im/canjs/canjs?at=56e8748f0055f8f35a837e6b)
