My own Google Chrome extension stops working after some time, because setTimeout() is not working in some cases.
Therefore the background script is not sending a message to the content script after some necessary delay.
I have found this problem by writing many console.log() statements.
As a solution i thought about using setInterval() until the message is sent to the content script:
var timer = setInterval(function() {
clearInterval(timer);
// Sending a message to the content script
}, 3000);
My code before, during and after setInterval() is quiet long, so i hope this code snippet is somehow enough.
Does anyone know in which cases these Timeouts or Intervals do not start?
Or are there any similar options i could use?
I have thought about using the Chrome Alarms API instead, but alarms can only be used once every minute and the minimum delay is one minute if i am not mistaken.
I never experienced any issue of setinterval or settimeout stops working. I guess there might be an issue in your code. If you are sure about the bug you should make a demo project and report bug on github.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.