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

116
Views
Netlify background function returns after it (Done executing background function handler-background)

My code in local works fine, but in Netlify it doesnot. Iam not sure whats happening. The flow is I generate invoices using easy invoice package and trying to upload it to s3 in async. But my code executes on the netlify platform wierdly.

generating invoice...
called in
◈ Done executing background function handler-background [here it actually exits, i think]
called out

My code is like this:

const generateInvoice = async (data) => {
  let  base64FileString = '';
 
      try {

        console.log("called in")
        base64FileString = await createInvoice(data); (---> this is creating problems, internally it returns a promise)
        console.log("called out")
      } catch(e) {
        console.log("Cannot create invoice ==> ", e)
        return;
      }

    return base64FileString.pdf;
  }
};

At the output, you can see the called in is printed and then it exits ◈ Done executing background function handler-background and again after some time, it print called out

This happens only on netlify function:serve (i.e) dev environment

But in Netlify platform it stops at the called in

Some help is appreciated.

Normal invoke of this function works properly (i.e) node <filename>

Any javascript issue here??

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue, I was having multiple await calls inside a loop. Using Promises.all(<loop code goes here>) and instead of forEach for looping using map solved the issue.

Also If I was having a callback function in between on a Promise based approach. Changing that to promise cleared the issue.

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!