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

153
Views
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 answers
Answer question

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 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!