question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

drops later execution after sleep

See original GitHub issue

Hi, we’re seeing that some later invocations aren’t executed on schedule after a system comes back from sleep.

The system has a long running later (every ~15min = 900000ms). After the system comes back from sleep, it triggers (caused by a failing network request) a 4s later execution which sometimes isn’t getting executed.

backburner-later-issue

To debug the issue, we start a regular setTimeout in parallel to the later execution. The setTimeout callback gets called 4s after executing it (see [global]).

The later execution looks like this:

  • now + wait = 1539002635660
    • which is the same time the native setTimeout gets executed (~ Mon Oct 08 2018 14:43:55 GMT+0200 (Central European Summer Time))

https://github.com/BackburnerJS/backburner.js/blob/master/lib/index.ts#L646

  • timers length is not 0 and searchTimer returns 6
    • this means _reinstallTimerTimeout isn’t called

https://github.com/BackburnerJS/backburner.js/blob/master/lib/index.ts#L654

From the looks of it, this means that the scheduled timer isn’t registered, which means it won’t execute on time. In the screenshot, we see the ember concurrency timeout never yields in the 4000 case (no [concurrency] executing later cb 4000 logged).

My guess is that it isn’t scheduled and the next timer that triggers is the longer running one.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kanongilcommented, Oct 8, 2018

Your cheap solution would not work if it immediately goes to sleep, and wakes up slightly before the executeAt, and install the new timer. In that case it could still have to wait ~15 min to fire.

0reactions
kanongilcommented, Oct 8, 2018

I just checked in Chrome and Safari for Mac, and they behave in the same way (pausing timeouts during system sleep). This is unfortunate.

I think the only reliable solution, is to reinstall the timer on each call to _later(). While this might look a bit weird on the already scheduled timers, it will ensure that new timers are handled properly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

swing - Java sleep() stops execution of code before the actual ...
I have a gui and I want to display some text and then wait a little. ... The ActionListener's code will be called...
Read more >
Thread.sleep() in Java - DigitalOcean
The Java Thread.sleep() method can be used to pause the execution of the current thread for a specified time in milliseconds.
Read more >
Windows 10 pro loss of internet after sleep / hybernation
Go to Settings > Network & Internet > WIfi > Manage Known Networks, highlight and remove the network having problems, restart PC to...
Read more >
Run Program When Windows Resumes from Sleep or Hibernate
Run Program on Resume from Sleep/Hibernate with Task Scheduler ... At the top of this Panel, choose “On an event” from the drop-down...
Read more >
How to pause a Thread in Java? Thread.sleep and TimeUnit ...
By using the sleep() method, you pause the current for some given time. You should never use sleep() in place of wait() and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found