question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error "Callback was already called." even when was not called.

See original GitHub issue

Error “Callback was already called.” occurs when is no callback called. Look at my code, it looks like some overloading issue.

Test case:

  const listJobs = (next) => {
    next(null, {
        queued: {},
        running: {},
        done:{},
    });
    return null;
  };

  const getSystemInfo = (next) => usage.lookup(process.pid, next);

  async.parallel([
    getSystemInfo, // its function, calls callback "(err, next)"
    listJobs, // its function, calls callback "(err, next)"
  ], (err, result) => {
    if (err) {
      return;
    }
    result[0].queued = 1; // HERE is the problem. it looks like overloading issue
  });

Async version: 2.0.1, Node.js v 6.2.2, Babel transpiler for ES6.

Expected: Assign variable to object property. Yes, it is for 100% an object.

Actual: /Users/webserver-nodejs/spider-crawler/node_modules/async/dist/async.js:844 if (fn === null) throw new Error(“Callback was already called.”); ^

Error: Callback was already called. at /Users/webserver-nodejs/spider-crawler/node_modules/async/dist/async.js:844:36 at /Users/webserver-nodejs/spider-crawler/node_modules/async/dist/async.js:3676:17 at /Users/webserver-nodejs/spider-crawler/node_modules/async/dist/async.js:339:31 at /Users/webserver-nodejs/spider-crawler/node_modules/usage/lib/providers/ps.js:21:9 at ChildProcess.exithandler (child_process.js:198:7) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:852:16) at Socket.<anonymous> (internal/child_process.js:323:11) at emitOne (events.js:96:13)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
hargasinskicommented, Sep 8, 2016

Thanks for the report! async.parallel is expected to throw an error if one of the tasks calls callback (or next in this case) more than once. I tried running the test case, both transpiled and not, and it ran without an error, so like you said, it’s probably another library you’re using calling it multiple times.

Also, what makes you say that it is the assignment causing the error? If removing a library removed the error, and since the error stack doesn’t mention anything about it, could the cause of error be something else?

0reactions
ddzyancommented, Jun 3, 2021

I also getting callback “already called error”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error - node_modules : Callback was already called
It seems vuejs (or webpack - not entirely sure) is very case sensitive to the file and folder names, I had various case...
Read more >
CCL1043: Error when launching development server ...
CCL1043: Error when launching development server 'Callback was already called.' Go to solution.
Read more >
Error: Callback was already called - Agents
Hi @jimmy.shimizu, so it looks like we recently released version 4.13.0 of our Node agent, which may help with the behavior you're seeing...
Read more >
Uncaught Error: Callback was already called in mocha
One issue is that you pass a constructor argument ( Hi there! ), but your contract doesn't take any constructor arguments, so this...
Read more >
Node async callback was already called when trying to ...
You are iterating over drafts synchronously and calling async's callback function on the first item. Getting an error when you try to call...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found