Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda