Skip to content

setTimeout sometimes doesn't trigger for a long time. #33372

@aksprncs

Description

@aksprncs

Node Version: 4.8.x
Linux METRICS03 4.15.0-1071-azure #76-Ubuntu SMP Wed Feb 12 03:02:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux-->

What steps will reproduce the bug?

  1. Set a timeout to call another function foo.
  2. Do some processing in foo and post processing set a timeout to call foo again.

It is observed that after numerous repetition foo doesn't get called at scheduled interval. Instead foo is called 3-4 hours later (sometimes even longer).

main() function is called when service starts.
`
var timerIntervalForJobProcess = 156060*1000;
main(){
processJob("abc")
}

var processJob = function(client){
logger.debug("in processJob");
processJobRecord(client)
.then(function (result) {
setNextExecutionForClient(client);
})
.catch(function (err) {
setNextExecutionForClient(client);
});
}

var setNextExecutionForClient = function (client) {
logger.info("Attempting to schedule job processing to execute again after " + timerIntervalForJobProcess + " milliseconds" + "for client: "+ client);
setTimeout(function(client) {
logger.info("in anonymous function in setNextExecutionForClient going to call processJob for client: "+ client);
processJob(client);
},
timerIntervalForJobProcess, client);
logger.info("Successfully scheduled job processing to execute again after " + timerIntervalForJobProcess + " milliseconds" + "for client: "+ client);
}`

How often does it reproduce? Is there a required condition?

It is happening approximately once in a week. Issue is observed randomly.

What is the expected behaviour?

Timeout scheduled function should execute close to 15 minutes. Few minut delay is okay but 3-4 hours of delay is not durable in the service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions