Karma and Chrome: Configuring retry behavior for browser disconnects
0 reputation · 18 Aug 2023, 16:15 UTC
When running tests in Karma with Chrome, a browser may disconnect unexpectedly due to network hiccups or resource constraints. The goal is to determine whether Karma can be tuned to retry a disconnected browser more aggressively or to give up after a configurable number of attempts.
Current configuration options include browserDisconnectTimeout, browserDisconnectTolerance, and browserNoActivityTimeout. However, the retry logic that kills the current instance and launches a new one is hardcoded, and there is no flag to set the maximum retry count before failure. The community has proposed a browserRetry flag, but it remains unmerged.
Additionally, in autoWatch mode, a disconnect during a watch cycle may cause Karma to skip a retry and exit with an error, producing flaky CI builds. The behavior for browsers that do not support WebSocket is also unclear, as the tolerance setting is ignored.
Given these uncertainties, the following questions remain:
- Is there a way to configure the number of retry attempts Karma will make before abandoning a disconnected browser?
- What is the exact behavior of Karma when a browser disconnects during an autoWatch cycle, and does it differ between Chrome and other browsers?
- Has the proposed
browserRetryflag been merged into any release, or is there an alternative workaround?