test(ci): harden Karma browser tests against launch flakiness under allTests#705
Merged
Merged
Conversation
…llTests
During `allTests` (run on every CI PR/push) ~20 wasmJs/js *BrowserTest tasks
each start a ChromeHeadless instance concurrently. On a loaded machine a browser
can exceed Karma's default capture/activity timeouts and get dropped
("Disconnected, no message in 30000 ms" / "ChromeHeadless was not killed"),
after which Karma discovers zero tests and Gradle fails the build on its
`failOnNoDiscoveredTests` check -- even though the tests pass in isolation.
This surfaced as :skainet-data:skainet-data-api:wasmJsBrowserTest failing.
Add a karma.config.d/skainet-browser-resilience.js to every browser-test module
(merged into karma.conf.js by the Kotlin Gradle plugin) that raises the
capture/disconnect/no-activity timeouts and adds disconnect tolerance, so a
CPU-starved browser is waited on instead of abandoned. Applied across all
browser modules so the flakiness can't simply hop to a different one.
Verified: `./gradlew allTests --rerun-tasks` green (all browser tasks
re-executed concurrently, 2m41s).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
📖 Documentation Preview The documentation has been built successfully for this PR. Generated Files:
Artifacts:
This comment will be updated automatically when the PR is updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
allTests(run on every CI PR/push, and locally) intermittently fails a browser test with:This surfaced as
:skainet-data:skainet-data-api:wasmJsBrowserTestfailing during a fullallTestsrun, while the same task passes every time in isolation.Root cause
Not a test bug — a flaky browser launch under concurrency.
allTestsstarts ~20wasmJs/js*BrowserTesttasks at once, each spinning up its own ChromeHeadless. On a loaded machine a browser exceeds Karma's default capture/activity timeouts (Disconnected, no message in 30000 ms/ChromeHeadless was not killed), Karma drops it, reports zero discovered tests, and Gradle fails the build on itsfailOnNoDiscoveredTestscheck. CI is the worst case for this:ubuntu-latest,-Xmx4g, and PRs runclean assemble allTestsso every browser test re-executes from scratch.Fix
Add a
karma.config.d/skainet-browser-resilience.jsto every browser-test module (the Kotlin Gradle plugin merges these into the generatedkarma.conf.js). It raises the capture/disconnect/no-activity timeouts and adds disconnect tolerance, so a CPU-starved browser is waited on instead of abandoned:These knobs are not exposed by Kotlin's
useKarma {}Gradle DSL, so akarma.config.d/*.jsfile is the supported way to set them. Applied across all browser modules (23 files) so the flakiness can't simply hop to a different module on the next run.Verification
./gradlew allTests --rerun-tasks— forced every test task (incl. all browser tasks) to actually re-execute concurrently rather than hit the cache. BUILD SUCCESSFUL in 2m41s, no failures, no "did not discover any tests", no browser launch errors.🤖 Generated with Claude Code