DEV Community

Libme
Libme

Posted on

GitHub Actions "Canceling since a higher priority waiting request exists": Concurrency Settings for CI vs Deploys

Short answer: that message means a concurrency group is working as designed. GitHub allows one running and one pending run per group, and a newer pending run replaces the older pending one. For CI you usually want that. For deploys you usually don't, so set cancel-in-progress: false on deploy workflows and key the group to the thing you're protecting (an environment), not to the branch.

What does the message actually mean?

You push twice in quick succession, and the first run's annotation reads:

Canceling since a higher priority waiting request for 'CI-refs/heads/main' exists
Enter fullscreen mode Exit fullscreen mode

or the run is simply marked "Canceled" with no step failing. Nothing is broken. A workflow like this caused it:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
Enter fullscreen mode Exit fullscreen mode

The rules, as documented by GitHub as of late 2026:

  • Per concurrency group, at most one run is in progress and at most one is pending.
  • If a new run arrives while one is already pending, the older pending run is canceled. This happens even when cancel-in-progress is false.
  • With cancel-in-progress: true, the new run also cancels the one that's currently running.

That second bullet is what surprises people. Without cancel-in-progress, runs queue, but the queue is one deep. Push three commits fast and the middle one disappears.

Takeaway: a concurrency group is a one-slot queue, not an unbounded one, so anything you can't afford to skip must not share a group with newer work.

Why did my deploy get canceled halfway?

The common failure: someone copies the CI snippet above into a deploy workflow. Commit A starts deploying (migration running, half the containers swapped). Commit B lands, cancel-in-progress: true kills A mid-step, and B starts against a half-migrated environment. The cancellation is clean from GitHub's point of view, but your infrastructure isn't transactional.

Typical dead ends:

  1. Adding if: always() cleanup steps. Cancellation does run always() steps, but you can't undo a half-applied migration from a cleanup step.
  2. Removing concurrency entirely. Now two deploys can run at once and race each other, which is worse.
  3. Using github.sha in the group name. Every commit gets its own group, so nothing serializes. It looks like concurrency control but does nothing.

The fix is to serialize without canceling:

name: deploy
on:
  push:
    branches: [main]

concurrency:
  group: deploy-production
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/deploy.sh
Enter fullscreen mode Exit fullscreen mode

Now deploy A finishes, then the newest pending commit deploys. If three commits arrive during A, the middle one is dropped, which is fine here because the last one contains it. Deploys of every commit in order would need a different design (a real queue), but "deploy the latest main" is what most teams want.

Takeaway: for deploys, key the group to the target environment and turn cancellation off; let the one-slot queue skip stale commits instead of killing in-flight ones.

How should I configure CI and deploy differently?

Workflow Group key cancel-in-progress Why
PR tests/lint workflow + PR ref true Old commit's results are obsolete
Push to main (tests) workflow + ref false You want a result for each main commit, at least the latest
Deploy fixed per environment false Never kill a deploy mid-flight
Scheduled/cron jobs fixed per job false Overlap risk, but skipping a run beats killing one
Docs/preview builds workflow + PR ref true Only the latest preview matters

The pattern I use for a single CI file that handles both PRs and main, so you cancel on PRs but never on main:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
Enter fullscreen mode Exit fullscreen mode

The || fallback matters. On push events github.event.pull_request.number is empty, so the group falls back to the ref. On pull requests, using the PR number is more stable than github.ref (refs/pull/N/merge) and groups runs the same way if you later add other triggers.

Takeaway: one expression, cancel-in-progress: ${{ github.event_name == 'pull_request' }}, gives you cancel-on-PR and never-cancel-on-main from a single block.

What are the gotchas with concurrency groups?

  • Group names are shared across the whole repository, not per workflow. Two workflows that both say group: production will block each other. That's useful when intentional (a deploy and a rollback workflow sharing a lock) and a confusing stall when accidental. Include github.workflow in the name unless you want sharing.
  • Job-level concurrency exists too. You can put concurrency on a single job, e.g. only the deploy job, while tests in the same workflow run freely. A pending job waits with status "Queued" and no logs, which looks like a hang.
  • Required checks and canceled runs. A canceled run doesn't satisfy a required status check, but the newer run for the same PR will. The trap is canceling on main when branch protection or a downstream workflow depends on every commit's result.
  • Group names are case-insensitive per GitHub's docs, so Deploy and deploy collide.
  • Self-hosted runner queues are separate. Concurrency is about workflow runs, not runner capacity; a run can be "not canceled" and still wait for a runner.

I'd verify behavior once on a throwaway branch: push two commits within seconds with a sleep 60 step, and watch which run survives. It takes five minutes and removes the guesswork.

Takeaway: concurrency groups are repo-wide names, so a typo'd or duplicated group is a lock shared with workflows you forgot about.

FAQ

Why does GitHub Actions cancel my workflow run even though I didn't cancel it?
A concurrency block with cancel-in-progress: true cancels the running job when a newer run enters the same group. Even without it, a newer pending run replaces an older pending one.

Does cancel-in-progress: false queue every run?
No. Only one run can be pending per group, so extra runs in a burst are canceled in favor of the newest. Use a separate queue mechanism if every commit must deploy in order.

What should the concurrency group be for a deploy workflow?
A fixed string per target environment, such as deploy-production, with cancel-in-progress: false. Don't include the commit SHA or branch, or nothing will be serialized.

Bottom line

Use cancel-in-progress for anything whose result becomes obsolete when a newer commit arrives: PR tests, lint, preview builds. Use a fixed per-environment group with cancellation off for deploys, migrations, and anything that mutates real infrastructure. If you need every commit deployed in order, a concurrency group isn't enough and you need an actual queue.

Related reading

Top comments (0)