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

213
Vistas
Async/Await promise being called twice

I'm trying to check if a connection exists after attempting to delete it. At this point the connection has already been deleted and it is now about to start checking once every second for 10 seconds. This is to make sure the user cant queue up multiple deletes before the first one has finished.

Everything seems to be working fine but I'm getting TWO Connection not found. Deleted successfully. I'm not quite sure why the resolve() portion of the code is being executed twice. Any help or advice would be great!

  // delete_network_status set to running
  // connection deleted

  return new Promise(async (resolve, reject) => {
    const checkDeleted = async (timeout_remaining) => {
      if (timeout_remaining <= 0) {
        ipc.server.broadcast("delete_network_status", "stopped");
        resolve();
      }
      try {
        // GetConnectionByUuid will fail if no connection exists
        await settings_iface.GetConnectionByUuid(toDeleteUUID);
      } catch (error) {
        console.log("Connection not found. Deleted successfully");
        ipc.server.broadcast("delete_network_status", "stopped");
        resolve();
      }
      console.log("Connection was found. Checking again...");
      await timeout(1000);
      await checkDeleted(timeout_remaining--);
    }
    
    //Set delay to 10 seconds
    await checkDeleted(10); 
  });
about 4 years ago · Juan Pablo Isaza
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