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

176
Vistas
Question about unhandled promise rejection in async function Javascript

I need to return something inside the catch block instead of throwing an error. Inside the catch block I'm executing retryGenerateThing function recursively and if the retry is greater than or equal to 3 return with status code 503. It looks like I'm not using catch block and just returning inside if else statement which is causing an issue but not sure how to resolve this issue. Below is the error I'm getting.

(node:8852) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

    try {
        await generateThing(ID)
    } catch (err) {
      const retryGenerateThing = async () => {
            
            const result = await getRetryCount(ID)
            retryCnt = result[0].RETRY_CNT

            if(retryCnt < 3) {
                try {
                    await generateThingRetry(ID)
                } catch (err) {
                    retryGenerateFactors()
                }
            } else {
                return res.status(503).send('FAILED - generateThing')   
            }
        }

        retryGenerateThing()
}
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