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

119
Vistas
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 Respuestas
Responde la pregunta

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