question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Add an API to recover after DISCONNECT

See original GitHub issue

Thanks 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
devoto13commented, Aug 4, 2021

Is that future proof-ish? 😅

Yes, I would say so!

Would there still be a possibility to start a new one automatically? Or will that be the default behavior?

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.

If you want I can validate any changes you make to karma before release.

Thanks! I’ll ping you once that PR is ready for testing.

0reactions
nicojscommented, Oct 28, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Amazon API Gateway FAQs - AWS
Read our Amazon API Gateway Frequently Asked Questions (FAQs) to learn about API management and logging, API security, API caching, pricing, and more....
Read more >
Add & manage connections with the API – Notion Help Center
Retrieve an internal API token. Visit the developer's website or contact their support. View users with access to the connection. Disconnect the connection ......
Read more >
XERO api remove tenant connections after login
So, the shorter answer is - no, you won't be able to make api calls after disconnecting. Share.
Read more >
Web API methods | Slack
getFileRetrieve analytics data for a given date, presented as a compressed ... disconnectSharedDisconnect a connected channel from one or more workspaces.
Read more >
Disconnecting and Reconnecting a Host - VMware Docs
You can disconnect and reconnect a host that a vCenter Server system ... the ESXi host reconnects automatically to vCenter Server after ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found