setup-node: Errors out on npm cache (no changes, worked fine until now)

Description: The Setup Node.js action fails with Error: Cache service responded with 422. This was not happening until today and now it happens on the three existing repos I tried, plus the new minimal repro linked below. Using cache: 'npm'. Full log:

Run actions/setup-node@v2
Found in cache @ /opt/hostedtoolcache/node/22.14.0/x64
/opt/hostedtoolcache/node/22.14.0/x64/bin/npm config get cache
/home/runner/.npm
Error: Cache service responded with 422

Action version: v2

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version: node v22.14.0 on ubuntu locally, “22” in GitHub runner.

Repro steps:
https://github.com/bhaugeea/tmp

Expected behavior: Until now the CI job in the repro succeeded.

Actual behavior: Node-setup errors on an npm cache interaction.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 15
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @bhaugeea, thanks for reporting this issue!

The error is occurring because setup-node@v2 relies on a deprecated version of @actions/cache. Upgrading to setup-node@v4 should resolve this issue, as it uses the updated version of the cache service.

To fix this and prevent any further caching problems, please update your workflows to use actions/setup-node@v4.

For more details, you can refer to the discussion here: GitHub Actions Toolkit Discussion.

Feel free to reach out if you need further assistance or clarification!

I’m the guy showing up right on April 15th! 😅

While actions/setup-node@v2 may continue to function for now, it relies on an outdated version of actions/cache, which is scheduled for permanent shutdown on April 15th.

Thanks for the information!

Hi @bhaugeea, Thank you for the update! The behavior you’re seeing is likely due to a recent brownout event affecting actions/cache, which temporarily disrupted the deprecated cache service.

While actions/setup-node@v2 may continue to function for now, it relies on an outdated version of actions/cache, which is scheduled for permanent shutdown on April 15th.

To avoid any interruptions and ensure ongoing reliability, we strongly recommend migrating to actions/setup-node@v4, which is fully compatible with the updated and supported cache service.

If you encounter any challenges during the migration or need further assistance, please feel free to reach out.

We’re on setup-node@v4.0.4 and still hitting this as a warning with cache: yarn:

All dependencies are managed locally by yarn3, the previous cache can be used
Warning: Failed to restore: Cache service responded with 422

During the Post job cleanup, it is failing out pipeline with an error:

Path Validation Error: Path(s) specified in the action for caching does not exist

which I’m currently suspecting is due to the cache miss.

I still encounter the warning after upgrading to v4: Warning: Failed to restore: Cache service responded with 422.

Hi everyone, As mentioned earlier, the root cause stems from actions/setup-node@v2 relying on a deprecated version of @actions/cache. Upgrading to actions/setup-node@v4, which uses the latest cache service, resolves the problem.

To prevent similar errors and take advantage of the latest improvements, we strongly recommend updating your workflows to use actions/setup-node@v4.

Since the root cause has been identified and a recommended solution is available, we are proceeding to close this issue. If you run into related problems after upgrading or have any further questions, please feel free to follow up here or open a new issue. Appreciate everyone’s input and collaboration!

Image it will be ok when change the version.

Hi @leoskyrocker 👋, Since you’re using setup-node@v4.0.4, which relies on an older version of actions/cache, and this can lead to caching problems or compatibility issues. To resolve this, please upgrade to the latest version of actions/setup-node, either by specifying setup-node@v4.4.0 or by using the v4 tag. The v4 tag will always point to the most up-to-date version, including the latest fixes and improvements for caching. Here’s how you can update your workflows:

uses: actions/setup-node@v4 # Or actions/setup-node@v4.4.0 Let us know if that works or if you run into any further issue.

I use the v4 but still get the same error

Image

Image

Hi @leoskyrocker 👋, Since you’re using setup-node@v4.0.4, which relies on an older version of actions/cache, and this can lead to caching problems or compatibility issues. To resolve this, please upgrade to the latest version of actions/setup-node, either by specifying setup-node@v4.4.0 or by using the v4 tag. The v4 tag will always point to the most up-to-date version, including the latest fixes and improvements for caching. Here’s how you can update your workflows:

uses: actions/setup-node@v4  # Or actions/setup-node@v4.4.0

Let us know if that works or if you run into any further issue.