Problem with setTimeout and setInterval

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
enco.josh
Posts: 35
Joined: 10 Mar 2014 22:10

Problem with setTimeout and setInterval

Post by enco.josh »

I have been using setInterval and setTimeout with no problems until today. I tried adding another setTimeout to my main.js file and it just would not run.

Code: Select all

var console = {
    log: debugPrint,
    warn: debugPrint,
    error: debugPrint,
    debug: debugPrint,
    logJS: function() {
        var arr = [];
        for (var key in arguments)
            arr.push(JSON.stringify(arguments[key]));
        debugPrint(arr);
    }
};

setTimeout(function() { 
	console.log("timeout 1");
}, 1000); 

setTimeout(function() { 
	console.log("timeout 2");
}, 1000); 
My only console output is timeout 2. Am I doing something wrong? Is there a workaround?
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: Problem with setTimeout and setInterval

Post by PoltoS »

Which version of Z-Way do you use? Does things change if you make delays different?
enco.josh
Posts: 35
Joined: 10 Mar 2014 22:10

Re: Problem with setTimeout and setInterval

Post by enco.josh »

Z-Way 1.7.1

Yes, if I change either timeout to 2000 ms (not both), they both execute.
enco.josh
Posts: 35
Joined: 10 Mar 2014 22:10

Re: Problem with setTimeout and setInterval

Post by enco.josh »

However, this code doesn't work. Only the timeout executes. Similarly, if I call setTimeout prior to setInterval, only the interval executes. It doesn't matter if the intervals are the same or not. Only the second one executes. I do have

Code: Select all

setInterval(function() {
	console.log("interval");
}, 1000);

setTimeout(function() {
	console.log("timeout");
}, 2000);
Post Reply