[Bug?]: Parallel execution of yarn workspace $name version apply
is unstable
#6615
Labels
bug
Something isn't working
yarn workspace $name version apply
is unstable
#6615
Self-service
Describe the bug
Running multiple instances of
yarn workspace $name version apply
causes unpredictable behavior.Bug model
At its core, I believe this is a race-condition bug.
Multiple processes attempting to read and modify the same files will inevitably encounter race conditions. Since there is no cross-process orchestration, multiple processes might read the stale version of a given file before performing the assumed update.
To reproduce
yarn version apply
, consider creating multiple version files, to increase the chances that the problem will surface.yarn workspace $name version apply
for each workspace in parallel.Environment
System: OS: macOS 14.6 CPU: (12) arm64 Apple M2 Pro Binaries: Node: 20.11.0 - /private/var/folders/5y/s8blq1h50fn7_qbwt5cndstw0000gq/T/xfs-b7f99751/node Yarn: 4.1.1 - /private/var/folders/5y/s8blq1h50fn7_qbwt5cndstw0000gq/T/xfs-b7f99751/yarn npm: 10.2.4 - ~/.asdf/plugins/nodejs/shims/npm
Additional context
This bug causes issues in teams wanting more control over which workspaces are bumped or how to apply the version bump (i.e. bump as a prerelease) in a given release.
The problem would be solved if yarn provided a way to apply the version bump on multiple workspaces at once, which will allow yarn to make sure all updates to .yarn/versions files are atomic. At the moment,
yarn version apply
only allows--all
- to apply the version bump on every workspace.There isn't enough control to apply a
prerelease
bump to a subset of the workspaces, or to apply a typical bump to a subset of workspaces.Workarounds
At the moment, I'm choosing to run each
yarn workspace $name version apply
sequential order. At the moment of writing this, running this in a monorepo with 150 workspaces takes ~15 minutes.The text was updated successfully, but these errors were encountered: