actions / actions/setup-node

pnpm cache race condition when using different node versions between workflows

Open
#641 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature request needs eyes
Dominant language
TypeScript
Stars
5k
Forks
1.7k
Avg merge
3d 12h
Merged PRs (30d)
2

Description

Description:

Same cache us being reused, regardless of node versions. This brings prolonged time for once of the operations, and cache race conditions.

As can be seen from the images attached below, same cache key is used for both, but once is using node14, while the other is using node16.

Action version:
actions/checkout@v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:

This is my Tests yaml

name: Tests

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  exec:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: pnpm/action-setup@v2
        with:
          version: 7

      - name: Install Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 14
          cache: "pnpm"

image

This is my Version yaml

name: Version

on:
  push:
    branches:
      - master

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
  version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: pnpm/action-setup@v2
        with:
          version: 7

      - name: Install Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: "pnpm"

image

Expected behaviour:

Node version is taken into account on the cache generation key.

Actual behaviour:

Same cache is being used, which leads to longer pnpm install steps, and cache race conditions.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report provides workflow examples using actions/setup-node@v3 and pnpm/action-setup@v2; start by tracing the pnpm cache-key generation used by setup-node. Compare the generated keys for Node 14 and Node 16, then verify that separate keys prevent the reported cache reuse and race condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, node.js, typescript
Domain
ci-cd, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.