Proposal: Add an API to recover after DISCONNECT
See original GitHub issueThanks again for the awesome work on Karma. There might already be an API for what I’m asking, but I couldn’t find it. I hope I’m not wasting your time.
Current behavior
When running StrykerJS with karma (via @stryker-mutator/karma-runner
), the code under test is being changed and can have unexpected behavior. One of the possibilities is that an infinite loop is created. For example:
while (result) {
- this.x++;
+ this.x--;
if (this.x == 10) {
result = false;
}
}
This will result in the browser being really busy and not able to ping to the server, eventually causing a "Disconnected reconnect failed before timeout of 2000ms (ping timeout)"
error.
There currently is no way to recover from this. The browser isn’t restarted or closed and there is no way to force this in the karma API. The only solution is to close the entire node process and start a new one, which is very expensive (especially in scenario’s where webpack needs to rerun).
Desired solution
Add a way to recover from this scenario. For example:
const karmaConfig = { /*...*/ };
const server = karma.Server(karmaConfig);
server.once('browsers_ready', () => {
server.once('browser_error', () => {
// new proposed API here:
await karma.launcher.close(karmaConfig);
await karma.launcher.start(karmaConfig);
});
karma.runner.run(karmaConfig);
});
Additional question: would the solution in #3267 change this disconnect behavior?
Related issue #3267 https://github.com/stryker-mutator/stryker-js/issues/2989
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top GitHub Comments
Yes, I would say so!
Yes, there would be a possibility to start a new one. We actually already kill the disconnected browser. So the only real difference is that
browser_error
will be emitted immediately without waiting for the browser to potentially reconnect after the ping timeout.Thanks! I’ll ping you once that PR is ready for testing.
We’ve implemented our disconnect fix and it’s working ever since: https://github.com/stryker-mutator/stryker-js/blob/master/packages/karma-runner/src/karma-plugins/stryker-reporter.ts#L135-L151