I can do this with setImmediate.
https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate
setImmediate implementation via window.postMessage or process.nextTick or MessageChannel or script.onreadystatechange
https://github.com/YuzuJS/setImmediate/blob/master/setImmediate.js
1
solved Endless function calls in javascript