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

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

0

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

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!