Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda