defunctzombie/zuul — pull request #120 by mcous (2014-12-27 23:03:26+00:00)
Title: ensure browser.quit finishes before finishing SauceBrowser.shutdown

I was getting a problem whenever I ran my tests on SauceLabs (locally or from Travis) where the last browser in any series would always show the error "Test did not see a new command for 90 seconds. Timing out." (I don't know if this is the same bug as #76). Upon inspection of the SauceLabs logs, I noticed the last browser was not receiving a quit command (DELETE /session/:id).

In SauceBrowser, prior to df0ed8d, SauceBrowser.shutdown was called by the browser.quit callback upon test completion. Afterwards, it was called outside the callback. Moving it outside seems to allow the tunnel to be shut down prior to the browser receiving its shutdown command, leaving SauceLabs hanging. Downgrading to 1.16.1 fixed the issue.

Seeing as SauceBrowser.shutdown already calls browser.quit, I removed the browser.quit call from reporter.on 'done' callback, and rearranged SauceBrowser.shutdown to quit the browser first if it exists, and then continue shutting down in the browser.quit callback.