Change setInterval(function, 0) for setImmediate(function).