Skip to content

Fix race condition in Update Dependencies workflow #586

Description

@cratis-direct

Problem

The Update Dependencies workflow (.github/workflows/update-dependencies.yml) fails intermittently with a concurrent push conflict when running multiple npm package update matrix jobs in parallel.

Error

! [remote rejected] main -> main (cannot lock ref 'refs/heads/main': is at c96d2611989a558ae0784c1ab9043bc9373021f2 but expected 7e427a8777ec98506d62278bedfd2a6e8d3aa770)
error: failed to push some refs to 'https://github.com/Cratis/Samples'

Root Cause

The workflow contains a matrix job that updates npm packages in three directories concurrently:

  • Arc/React
  • Library/Lending
  • Library/Members

When these jobs run in parallel:

  1. All jobs checkout main at the same commit (e.g., 7e427a8...)
  2. Library/Lending finishes first and successfully pushes, moving main to c96d261...
  3. Arc/React then tries to push but fails because main has advanced
  4. The git push is rejected by the server as the base commit no longer matches expectations

This is a classic race condition where concurrent jobs on the same branch conflict.

Solution

Add a workflow-level concurrency group to serialize execution:

concurrency:
  group: update-dependencies
  cancel-in-progress: false

This ensures only one instance of the Update Dependencies workflow can run at a time. New runs will wait for existing ones to complete rather than being canceled.

Implementation

The fix requires modifying .github/workflows/update-dependencies.yml to add the concurrency configuration immediately after the on: section, before jobs:.

This is tracked by #585.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions