feat(file-lock): Added configurable retries for file-lock #886
+42
−15
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.
When test processes with isolated testcontainers are running in parallel they become very slow to start because of the file-lock retry strategy in testcontainers.
proper-filelock
usesnode-retry
(repo) and exposes options to configurenode-retry
behavior. The current option is{ retries: { forever: true } }
. This leaves the rest on defaults (factor
2
,minTimeout
1000
,maxTimeout
infinity
).This PR allows the user to configure some parts of the file lock retry strategy.
Example
Multiple tests are started in parallel with jest as different processes (default behavior). They start at the same time (default jest behavior).
Each test uses a
GenericContainer
and tries to start it. Because the process are started at the same time and use the same exponential back-off algorithm (node-retry) most of the time the processes check again on the same moment. This causes exponentially longer tests depending on how many are running in parallel.Tweaking the retry strategy to lower the
minTimeout
andfactor
can result in serious speed-up.