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

154
Vistas
Am getting UnhandledPromiseRejectionWarning in try catch block with async await

While implementing a graphql resolver function, I ran into an UnhandledPromiseRejectionWarning error. Am sending a request to classify some text and it's the classification that's throwing an error. I want to re-throw whatever error is thrown, but the error is not being caught in the catch block.

Am not awaiting the request because I am sending two other requests with the classify request in parallel, but am awaiting each request in a Promise.all function.

Here is the code:

createPost: async (
        _,
        { fields: { media, text, location } }) => {
        try {
            const firstRequest = languageClient.classifyText({
                document: {
                    content: text,
                    type: 'PLAIN_TEXT'
                }
            });
        const secondRequest = // another request
        const thirdRequest = // another request
        const result = await Promise.all([firstRequest, secondRequest, thirdRequest]);
    } catch(error) { throw error }
    
}

How do I handle the error properly?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Stupid me, I wrapped the Promise.all with an if statement, so it's not even running at all. That's the reason why am getting weird results. I just discovered this after 3 days. I'm so stupid.

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