Skip to content

Commit

Permalink
call callback at the end of all required responses or if there is an …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
Fabrice Ongenae authored and fabong committed May 22, 2018
1 parent ee7fd6c commit 8acba11
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/engine_socketio.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,15 @@ SocketIoEngine.prototype.step = function (requestSpec, ee) {
if (!err) {
markEndTime(ee, context, startedAt);
}
// Stop listening on the response channel only if all messages were received
if (requiredResponsesCountsByChannel[channel] - 1 === index) {
// Stop listening on the response channel only if all messages were received or if there is an error
if (requiredResponsesCountsByChannel[channel] - 1 === index || err) {
socketio.off(channel);
}
return callback(err, context);

// Call the callback function if all channel messages were received or if there is an error
if (requiredResponsesCount === currentResponsesCount || err) {
callback(err, context);
}
});
});
});
Expand Down

0 comments on commit 8acba11

Please sign in to comment.