Skip to content

Commit 9c894f9

Browse files
fix(executor): ensure run_complete is emitted last
Fixes #2210
1 parent 9b7cb64 commit 9c894f9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/executor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var Executor = function (capturedBrowsers, config, emitter) {
1717

1818
if (capturedBrowsers.areAllReady(nonReady)) {
1919
log.debug('All browsers are ready, executing')
20+
log.debug('Captured %s browsers', capturedBrowsers.length)
2021
executionScheduled = false
2122
capturedBrowsers.clearResults()
2223
capturedBrowsers.setAllToExecuting()
@@ -44,7 +45,11 @@ var Executor = function (capturedBrowsers, config, emitter) {
4445
pendingCount--
4546

4647
if (!pendingCount) {
47-
emitter.emit('run_complete', runningBrowsers, runningBrowsers.getResults())
48+
// Ensure run_complete is emitted in the next tick
49+
// so it is never emitted before browser_complete
50+
setTimeout(function () {
51+
emitter.emit('run_complete', runningBrowsers, runningBrowsers.getResults())
52+
}, 0)
4853
}
4954
}
5055

0 commit comments

Comments
 (0)