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

283
Visualizações
callback is not a function inside async library

I created this small code to reproduce the error I was getting inside an app:

const async = require("async");

function sleep(ms) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

const parallels = [];

for (let i = 0; i < 2; i++) {
  parallels.push(async function (callback) {
    const randomSleepTime = Math.ceil(Math.random() * 10000);
    await sleep(randomSleepTime);
    callback(randomSleepTime);
  });
}

async.parallel(parallels, function (err, results) {
  console.log(err);
  console.log(results);
});

I'm getting this error after this is done: TypeError: callback is not a function
Why exactly is this happening?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The solution is to return the value instead of using callback() which is mentioned here.

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