-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #1874 race condition #3561
Fix #1874 race condition #3561
Conversation
Don't forget to use clean cache when testing. Ideally, run this in a docker container which is destroyed on each run. |
What is a supposed way to update |
Because of the way Lerna works, you need to now reset your lockfile and run yarn install from project root |
:( wrong node version? |
Did yarn install, |
This is the diff I get, when I run diff --git a/packages/jest-runtime/yarn.lock b/packages/jest-runtime/yarn.lock
index c0121df..4eaff68 100644
--- a/packages/jest-runtime/yarn.lock
+++ b/packages/jest-runtime/yarn.lock
@@ -654,6 +654,13 @@ private@^0.1.6:
version "0.1.7"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1"
+proper-lockfile@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-2.0.1.tgz#159fb06193d32003f4b3691dd2ec1a634aa80d1d"
+ dependencies:
+ graceful-fs "^4.1.2"
+ retry "^0.10.0"
+
randomatic@^1.1.3:
version "1.1.6"
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb"
@@ -713,6 +720,10 @@ require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
+retry@^0.10.0:
+ version "0.10.1"
+ resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4"
+
"semver@2 || 3 || 4 || 5", semver@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" |
Use file locking to fix the race condition when writing the cache
As for destructuring, it doesn't seem to work very well (despite babel transform used, dunno) on Node 4, so we use |
Thanks, after removing |
All tests passed 🎉 One thing I'm not sure about is |
Let's just wait for @cpojer or @DmitriiAbramov to review this :) |
Codecov Report
@@ Coverage Diff @@
## master #3561 +/- ##
==========================================
- Coverage 62.39% 62.39% -0.01%
==========================================
Files 181 181
Lines 6646 6651 +5
Branches 6 6
==========================================
+ Hits 4147 4150 +3
- Misses 2496 2498 +2
Partials 3 3
Continue to review full report at Codecov.
|
hey @Vanuan! how did you test this? |
I'm using a docker image based on I've reviewed the coverage report and it looks like locking always fails :( Maybe I'm reading it wrong? |
i don't think coverage will be collected for this part, because most of the time we run Jest in subprocesses without any instrumentation |
Might also depend on the filesystem and flush policy. |
Hm, another difference might be SSD vs HDD. Don't know how to make fs module slower. Maybe add some loops in the wrapper module? |
How can I release my personal fork with this fix so that people in #1874 could verify? Or could you do that? |
@Vanuan if you put up a pull request anyone using the upstream/origin fork model can use the git cpr alias here to pull down the latest commit in the pull request to run locally - https://github.com/bcruddy/dotfile-manager/blob/master/home/.gitconfig |
I've tried this in
Resulted in error:
|
@Vanuan this won't work, because you have to build the project (run Jest code through Babel). What you need to do is to publish your npm package (change |
@thymikee Yeah, that's what I'm asking. Is there a script? Is it |
Yarn or npm, whatever: https://docs.npmjs.com/cli/publish |
@Vanuan anything we can to do help you make progress on this? |
We have a fix that doesn't use lockfiles in this PR: #4088 which we think is going to resolve this problem in a safer way. Thank you so much for experimenting with a fix and sending us a pull request :) |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Use file locking to fix the race condition when writing the cache
Test plan
Race conditions are tricky to reproduce, hence only manual testing.
Use some big modules that takes a long time to transform write to the filesystem, create multiple tests and run each test in a separate worker.