Skip to content

timers: eventloop is blocked when there are two or more callback duration is larger than interval #15068

Description

@zhangzifa
  • Version: 6.x 7.x 8.x master:
  • Platform: n/a:
  • Module: timers:

When there are at least two timer set by setInterval, whose callback execution time are longer than interval, the eventloop will be blocked, meanwhile the 4.x is not. You may take the following code to have a test.

@Fishrock123 It seems the timers module refactoring brings this.

const http = require('http');

const sleep = function(ms) {
  const st = new Date().getTime();
  while (new Date().getTime() < st + ms);
};

const t1 = setInterval(function(){
  sleep(100);
}, 50)

const t2 = setInterval(function(){
  sleep(60);
}, 50);

http.createServer(function(req, res) {
  res.end('hello ' + new Date());
}).listen(8888);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

timersIssues and PRs related to timers, setImmediate(), setInterval(), and setTimeout().

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions