Skip to content

Issue: Cache service responded with 404 with actions/setup-node@v2 #1034

Description

@aib

(I'm skipping the issue template since this looks more like an oversight or missing feature than a bug.)

actions/setup-node@v2, when run with cache: npm, fails with "::error::Cache service responded with 404".

To replicate, one can clone https://github.com/aib/act-setup-node-test and run act --artifact-server-path /tmp/act-artifacts -j test. Edit: Or use the following workflow file:

name: Test
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16.14.0
          cache: 'npm'
      - run: npm --version

Tested against release v0.2.25 and current master.

The requested URL looks like http://127.0.0.1:34567/_apis/artifactcache/cache?keys=node-cache-Linux-npm-4ae58fb93f5d99af5b6b62d6ba7d42110a267626bfc1d6847922d9e6863ef729&version=b3f0cb83629d634645a5146420c017462ebb5229bd60271a7a86e489a6066469 and seems to be generated by https://github.com/actions/toolkit/blob/main/packages/cache/src/internal/cacheHttpClient.ts#L33 .

A workaround is returning HTTP 204 to the request. An actual caching implementation should be easy, too, but I'm not familiar enough with act, GitHub Actions or even Go to submit a PR. (And in any case I'd need an issue # to reference)

Activity

  1. KnisterPeter commented on Mar 15, 2022

    @KnisterPeter
    Member

    Hi @aib,
    the asset server implementation in act currently does not support the github caching API.
    It only supports the artifact upload/download from jobs.

  2. ZauberNerd commented on Mar 15, 2022

    @ZauberNerd
    Contributor

    See also this comment for a solution to disable cache in the setup-x actions when running in act while still allowing cache on GitHub actions: #989 (comment)

  3. aib commented on Mar 15, 2022

    @aib
    Author

    Ahh, I see. Thanks.

  4. 3Nigma commented on Oct 4, 2022

    @3Nigma

    Hey guys! I was able to use

        - name: Bringing node v16
          uses: actions/setup-node@v3
          with:
            node-version: 16
            cache: 'npm'
            cache-dependency-path: client
    

    in act with a modified version of JEFuller's code written by me, conveniently named github-cache-server. 😊

    image

    This also works great with act's --artifact-server-path if you're planning to use the artifact server as well.

    Cheers 🍻

  5. iSplasher commented on Mar 26, 2023

    @iSplasher

    Would it be possible to integrate this directly into act?

  6. 3Nigma commented on Mar 27, 2023

    @3Nigma

    Would it be possible to integrate this directly into act?

    I would have, but I don't speak GO 😔

  7. shmuli9 commented on Jan 11, 2025

    @shmuli9

    Hey guys! I was able to use

        - name: Bringing node v16
          uses: actions/setup-node@v3
          with:
            node-version: 16
            cache: 'npm'
            cache-dependency-path: client
    

    in act with a modified version of JEFuller's code written by me, conveniently named github-cache-server. 😊

    image

    This also works great with act's --artifact-server-path if you're planning to use the artifact server as well.

    Cheers 🍻

    How do you set this up in your workflow file?

  8. louzt commented on Jul 28, 2026

    @louzt

    This is already fixed. The cache handler was rewritten in #1770 (April 2023) by @wolfogre — see pkg/artifactcache/handler.go find() function which now returns HTTP 204 (No Content) when no cache entry matches, instead of 404.

    The relevant test is TestHandler/get_not exist in pkg/artifactcache/handler_test.go:

    t.Run("get not exist", func(t *testing.T) {
        key := strings.ToLower(t.Name())
        version := "c19da02a2bd7e77277f1ac29ab45c09b7d46a4ee758284e26bb3045ad11d9d20"
        resp, err := http.Get(fmt.Sprintf("%s/cache?keys=%s&version=%s", base, key, version))
        require.NoError(t, err)
        require.Equal(t, 204, resp.StatusCode)
    })

    Verified locally on current master (4f41128). actions/setup-node@v4 with cache: 'npm' works against act's local cache server.

    Suggesting closure as already-resolved.

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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions