Skip to content

Commit 8acba11

Browse files
Fabrice Ongenaefabong
authored andcommitted
call callback at the end of all required responses or if there is an error
1 parent ee7fd6c commit 8acba11

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/engine_socketio.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,15 @@ SocketIoEngine.prototype.step = function (requestSpec, ee) {
228228
if (!err) {
229229
markEndTime(ee, context, startedAt);
230230
}
231-
// Stop listening on the response channel only if all messages were received
232-
if (requiredResponsesCountsByChannel[channel] - 1 === index) {
231+
// Stop listening on the response channel only if all messages were received or if there is an error
232+
if (requiredResponsesCountsByChannel[channel] - 1 === index || err) {
233233
socketio.off(channel);
234234
}
235-
return callback(err, context);
235+
236+
// Call the callback function if all channel messages were received or if there is an error
237+
if (requiredResponsesCount === currentResponsesCount || err) {
238+
callback(err, context);
239+
}
236240
});
237241
});
238242
});

0 commit comments

Comments
 (0)