Skip to content

Commit cb8fd1c

Browse files
committed
fix possible double callback
1 parent faaefd3 commit cb8fd1c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/contracts/deploy_manager.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,22 @@ class DeployManager {
133133
return callback(new Error("error running afterDeploy"));
134134
}
135135

136-
// TODO: convert to for to avoid repeated callback
137-
for(let cmd of onDeployCode) {
136+
async.each(onDeployCode, (cmd, eachCb) => {
138137
self.logger.info("executing: " + cmd);
139138
try {
140139
RunCode.doEval(cmd, web3);
141140
} catch(e) {
142141
if (e.message.indexOf("invalid opcode") >= 0) {
143142
self.logger.error('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation');
144143
}
145-
return callback(new Error(e));
144+
return eachCb(new Error(e));
146145
}
147-
}
146+
eachCb();
147+
}, (err) => {
148+
callback(err, contractsManager);
149+
});
150+
148151

149-
callback(null, contractsManager);
150152
}
151153
], function (err, result) {
152154
if (err) {

0 commit comments

Comments
 (0)