Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
NodeJS v12.18.1 SetInterval stops running after a few days

I am using a setInterval function to send a ping every minute, problem is that after an arbitrary number of days,the setInteval callback no longer gets executed. I am aware of the issue that was fixed in v10.9.0 https://github.com/nodejs/node/issues/22149, but this is is happening in version 12, and not after 25 days.

this is a simplified version of what I am using setInterval for:

startPing() {
  console.log(`will start sending pings in 60 seconds`)
  this.pingInterval = setInterval(() => {

    console.log("sending ping", new Date())
    this.socket.write('ping');
    // if no response is recieved after whenToTimeut number of seconds, invoke timeout to try to reconnect.
    const whenToTimeOut = 30* 1000
    this.socket.setTimeout(whenToTimeOut);
  }, 60*1000)
}

After reading about the issues with setInterval I've decided to use node-cron for now, I know it uses setTimeout under the hood, but we also have a process running using it, and it doesn't stop even when the ping process stops.

What I am wondering is, has anyone faced this issue before, and has anyone figured out a way to replicate it (couldn't do it using libfaketime), because even if I use the node-cron package, I still wanna make sure that it's the setInterval that was causing the issue.

PS. I've tried to look for any possible resource leakage problem, but couldn't find any, and the process is running fine aside from the ping process stopping.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!