New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: restarted browsers not running tests #3233
Changes from all commits
b4831c1
83f2493
4a1b33f
9c69aa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,10 +232,20 @@ class Server extends KarmaEventEmitter { | |
let newBrowser = info.id ? (capturedBrowsers.getById(info.id) || singleRunBrowsers.getById(info.id)) : null | ||
|
||
if (newBrowser) { | ||
// By default if a browser disconnects while still executing, we assume that the test | ||
// execution still continues because just the socket connection has been terminated. Now | ||
// since we know whether this is just a socket reconnect or full client reconnect, we | ||
// need to update the browser state accordingly. This is necessary because in case a | ||
// browser crashed and has been restarted, we need to start with a fresh execution. | ||
if (!info.isSocketReconnect) { | ||
newBrowser.setState(Browser.STATE_DISCONNECTED) | ||
} | ||
|
||
newBrowser.reconnect(socket) | ||
|
||
// We are restarting a previously disconnected browser. | ||
if (newBrowser.state === Browser.STATE_DISCONNECTED && config.singleRun) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What it a bug that this was using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that was a bug. The |
||
// Since not every reconnected browser is able to continue with its previous execution, | ||
// we need to start a new execution in case a browser has restarted and is now idling. | ||
if (newBrowser.state === Browser.STATE_CONNECTED && config.singleRun) { | ||
newBrowser.execute(config.client) | ||
} | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments are important but seem long. How about placing the comment inside the
if
and something like// Browser crashed and restarted.
(I really dislike the state-setting from outside design).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't think that it's a concern that this comment is long. Since this is basically a side-effect and we want to make clear why it happens, I think it's good to have this explained as detailed as possible. Especially since this seems to be a long-term and critical issue that can cause flaky test runs on CI's.
// Browser crashed and restarted
is basically a comment like below where it says// We are restarting a previously disconnected browser.
but basically misses crucial information.Also I agree with the state setting from outside being a bit weird, but I'd rather set it here than passing stuff back into the
Browser
. As a matter of the event flow and the data we need from the client socket, it kind of makes sense to me to handle it here. I'm up other ideas on how we can do it.