fix: race condition between the Karma shutdown and coverage writing#463
Merged
jginsburgn merged 2 commits intokarma-runner:masterfrom Feb 5, 2022
Merged
fix: race condition between the Karma shutdown and coverage writing#463jginsburgn merged 2 commits intokarma-runner:masterfrom
jginsburgn merged 2 commits intokarma-runner:masterfrom
Conversation
The creation of parent directories is asynchronous process, which was not properly awaited, which resulted in the coverage reports not being written to the disk sometimes as Karma process has exited before the reporter completed the writing of the coverage report. Also update the test case to use async implementation of the corresponding stub to prevent regressions in the future. Remove manual calls for `done` parameter in tests as it is handled by the stub now. Fixes karma-runner#434
3936737 to
372427f
Compare
The issue surfaced itself after d970028. The EEXIST error from concurrent attempts to create the same directory were previously silently swallowed, but started to show up once the call was properly synchronized. The EEXIST will now result in `promiseComplete` being rejected and reported as `unhandledRejection` because it is awaited in the `onExit` callback. The unhandled rejection is then picked up by `karma` [here](https://github.com/karma-runner/karma/blob/c985155a4eac95c525e1217e98d4013ac5f53305/lib/server.js#L395) triggering [the close logic](https://github.com/karma-runner/karma/blob/c985155a4eac95c525e1217e98d4013ac5f53305/lib/server.js#L392) which (among other things) will trigger `onExit` callback causing an infinite loop. The local fix is to handle the rejected promise directly and report failure to karma by passing a non-zero exit code.
jginsburgn
approved these changes
Feb 5, 2022
Member
|
🎉 This PR is included in version 2.1.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
The creation of parent directories is asynchronous process, which was not properly awaited, which resulted in the coverage reports not being written to the disk sometimes as Karma process has exited before the reporter completed the writing of the coverage report.
Also update the test case to use async implementation of the corresponding stub to prevent regressions in the future.
It seems that manually callingNah, probably they are just leftovers of the old reporter implementation.doneparameter in several tests was an attempt to solve the same race condition in the unit tests. They are not needed anymore.Fixes #434