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 committed May 10, 2017
1 parent 0c0f814 commit aa39e6c
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 @@ -197,11 +197,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 aa39e6c

Please sign in to comment.