setTimeout is not working
See original GitHub issuesetTimeout, setInterval and other interval built in methods do not work, even if I expose them in context.
console.log('start');
setTimeout(()=> {
console.log('hello timeout');
}, 2000);
console.log('end');
output:
start
end
It is to be noted that when I add .bind(this)
, then timeout works and breaks at that line saying .bind is not a function.
console.log('start');
setTimeout(()=> {
console.log('hello timeout');
}, 2000).bind(this);
console.log('end');
output:
start
hello timeout
// and an error in console saying setTimeout(...).bind is not a function
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Why is JavaScript's Set Timeout not working? - Stack Overflow
7 Answers 7 · Remove the parenthesis in setTimeout(startTimer(),startInterval); . Keeping the parentheses invokes the function immediately. · Your startTimer ...
Read more >Fix JavaScript setTimeout not working - Weekend Projects
This is due to when a function is executed as a parameter to setTimeout , the execution context is different to the execution...
Read more >setTimeout() - Web APIs | MDN
setTimeout () is an asynchronous function, meaning that the timer function will not pause execution of other functions in the functions stack. In ......
Read more >Javascript SetTimeout delay not working when trying to ...
I'm trying to implement automatic logout for mobile app for an N minutes. I used javascript node to call setTimeout() javascript function. I've...
Read more >Javascript bug: setTimeout is not always working - SitePoint
setTimeout (function () {try_conn (data.idPeer, stream); }, connect_time);. it works 70% of the time. But in about 30% of times it does not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tried checking your suggestion
vm.runInNewContext('code', { setTimeout: window.setTimeout })
but it doesn’t work. Custom setTimeout do work.If you say that the iFrame is destroyed in which the code was running then how my custom implementation of setTimeout and setInterval is working.
Even if I add
customSetTimeout
for 1 minute, it works