Node: timers: timer starvation

Created on 12 Nov 2018  路  2Comments  路  Source: nodejs/node

  • Version: 11.1.0 and master. 10.x is not impacted
  • Platform: macOS
  • Subsystem: timers

The following code should exit once the 110ms timer fires. Unfortunately, that never happens. Note, I tried including https://github.com/nodejs/node/pull/24318, and that did not fix the issue either.

'use strict';
let client = null;

function serverBeat() {
  setTimeout(() => {}, 45);
  setTimeout(serverBeat, 50);
  clientBeat();
}

function clientBeat() {
  clearTimeout(client);
  client = setTimeout(clientBeat, 95);
}

setTimeout(() => {}, 10000);
setTimeout(serverBeat, 50);
setTimeout(() => {}, 120000);
clientBeat();

setTimeout(() => {
  console.log('finished!');
  process.exit();
}, 110);

Refs: https://github.com/hapijs/nes/issues/257
cc: @nodejs/timers

confirmed-bug timers

Most helpful comment

Working on a PR 馃槗

All 2 comments

Working on a PR 馃槗

Fixed in 9ca5c52

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcollina picture mcollina  路  3Comments

stevenvachon picture stevenvachon  路  3Comments

vsemozhetbyt picture vsemozhetbyt  路  3Comments

dfahlander picture dfahlander  路  3Comments

danialkhansari picture danialkhansari  路  3Comments