【发布时间】:2018-05-14 10:27:15
【问题描述】:
谁能解释我为什么一直看到Error: Callback was already called。
我觉得我已经涵盖了所有案例 - 那为什么会被“已经调用”:
function addVertices(outercallback) {
async.forEachLimit(fullData, 25, function (data, innercallback) {
myJson.matches.forEach(function (oMatches) {
if (data.$.id == oMatches.SourceId) {
oMatches.Ids.forEach(function (oId) {
client.execute("g.addV('test').property('id', \"" + oId + "\")", {}, (err, results) => {
if (err) {
return innercallback(console.error(err));
}
innercallback(null)
});
})
}
})
}, outercallback);
}
事实上,我也尝试将第二个 forEach 替换为 async.ForEach,如下所示,但是这是正确的方法吗?:
function addVertices(outercallback) {
async.forEachLimit(fullData, 25, function (data, innercallback) {
async.forEach(myJson, function (oMatches, innercallback2) {
if (data.$.id == oMatches.SourceId) {
oMatches.Ids.forEach(function (oId) {
client.execute("g.addV('test').property('id', \"" + oId + "\")", {}, (err, results) => {
if (err) {
return innercallback2(console.error(err));
}
innercallback2(null)
});
})
}
innercallback(null)
})
}, outercallback);
}
【问题讨论】:
标签: azure azure-cosmosdb gremlin async.js