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

231
Views
How to make function run forever in the browser?

I have a simple function that fetches some data, shows it to the user (on a chart), wait for 10 minutes and starts again. After some time I get this error Error: timeout of 0ms exceeded

I found this supposed to happen if it can't connect to the internet, which cannot be the case.

Is chrome doing this maybe? I think it might freeze the app or something.

Here is the simple function:

    updateReports() {
      // checks for new data, waits the given time, and checks again.. forever
      this.$VKS.Read('Report', { filter: { shared: this.user }})
      .then(reports => {
        this.reports = reports // show the data to the user
        setTimeout(() => {
          this.updateReports() // start again
        }, 1000 * 60 * 10) // 10 minutes
      }).catch(err => console.error(err))
    },

Thank you for your help!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

if you get error(in this case Timeout) your codes never retry. you need to do the same in catch statement:

 updateReports() {
  // checks for new data, waits the given time, and checks again.. forever
  this.$VKS.Read('Report', { filter: { shared: this.user }})
  .then(reports => {
    this.reports = reports // show the data to the user
    setTimeout(() => {
      this.updateReports() // start again
    }, 1000 * 60 * 10) // 10 minutes
  }).catch(err => {
      console.error(err);
      setTimeout(() => {
       this.updateReports() // start again
      }, 1000 * 60 * 10) // 10 minutes
  })
},
about 4 years ago · Juan Pablo Isaza Report
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!