Error "Callback was already called." even when was not called.
See original GitHub issueError “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:
- Created 7 years ago
- Comments:7
Top GitHub Comments
Thanks for the report!
async.parallel
is expected to throw an error if one of thetasks
callscallback
(ornext
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?
I also getting callback “already called error”