Skip to content

setTimeout delayed when sleeping on Windows #6763

Closed
@seishun

Description

@seishun
  • Version: v6.1.0 and master
  • Platform: Windows 10 64-bit
  • Subsystem: timers

Testcase:

console.log(Date());
setTimeout(function() {
    console.log(Date());
}, 20000);

When running it normally, the result is as expected:

Sat May 14 2016 23:20:36 GMT+0300 (FLE Daylight Time)
Sat May 14 2016 23:20:56 GMT+0300 (FLE Daylight Time)

However, if you do the following:

  1. Start the script.
  2. Put the computer to sleep ASAP.
  3. Resume after 10 seconds.

The timeout fires not after the remaining 10 seconds, but after ~20 seconds:

Sat May 14 2016 23:22:14 GMT+0300 (FLE Daylight Time)
Sat May 14 2016 23:22:45 GMT+0300 (FLE Daylight Time)

I've asked on IRC and people say that this doesn't happen on Linux. That is, the callback is not delayed unless it would have occurred during sleep, in which case it's fired as soon as the computer wakes up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libuvIssues and PRs related to the libuv dependency or the uv binding.timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions