npm-install icon indicating copy to clipboard operation
npm-install copied to clipboard

Error: getCacheEntry failed: Cache service responded with 503

Open gr2m opened this issue 3 years ago • 54 comments

I have seen this error pop up several times in the past few days

image

The error seems to originate from this code, which does not seem to be part of this repository

function retry(name, method, getStatusCode, maxAttempts = constants_1.DefaultRetryAttempts, delay = constants_1.DefaultRetryDelay, onError = undefined) {
    return __awaiter(this, void 0, void 0, function* () {
        let errorMessage = '';
        let attempt = 1;
        while (attempt <= maxAttempts) {
            let response = undefined;
            let statusCode = undefined;
            let isRetryable = false;
            try {
                response = yield method();
            }
            catch (error) {
                if (onError) {
                    response = onError(error);
                }
                isRetryable = true;
                errorMessage = error.message;
            }
            if (response) {
                statusCode = getStatusCode(response);
                if (!isServerErrorStatusCode(statusCode)) {
                    return response;
                }
            }
            if (statusCode) {
                isRetryable = isRetryableStatusCode(statusCode);
                errorMessage = `Cache service responded with ${statusCode}`;
            }
            core.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`);
            if (!isRetryable) {
                core.debug(`${name} - Error is not retryable`);
                break;
            }
            yield sleep(delay);
            attempt++;
        }
        throw Error(`${name} failed: ${errorMessage}`);
    });
}

I've set ACTIONS_STEP_DEBUG to true for future runs and will let you know if that yields any helpful information.

The source code above suggests that maxAttempts might be configurable? Is there an option I can set to retry requests in case of a 503?

gr2m avatar Jan 21 '21 22:01 gr2m

I'm getting a similar error but with 403:

Run bahmutov/npm-install@v1
running npm-install GitHub Action
trying to restore cached NPM modules
Error: Cache service responded with 403
    at Object.<anonymous> (/home/runner/work/_actions/bahmutov/npm-install/v1/dist/index.js:3503:19)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/bahmutov/npm-install/v1/dist/index.js:3427:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Cache service responded with 403

bitttttten avatar Feb 08 '21 13:02 bitttttten

I have the same error as @bitttttten when trying to run my action on a pull_request closed event

jgoux avatar Mar 10 '21 23:03 jgoux

I'm getting the 403 error on pull_request closed too 👍🏼

Run bahmutov/npm-install@v1
running npm-install GitHub Action
trying to restore cached NPM modules
Error: Cache service responded with 403
    at Object.<anonymous> (/home/runner/work/_actions/bahmutov/npm-install/v1/dist/index.js:3503:19)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/bahmutov/npm-install/v1/dist/index.js:3427:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Cache service responded with 403

If it makes any difference, I'm checking out the HEAD branch of the pull_request:

      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
          ref: ${{ github.head_ref }}

aryella-lacerda avatar Apr 03 '21 14:04 aryella-lacerda

I am hitting the same issue today on one of the jobs, but not deployment_status

hhimanshu avatar Apr 17 '21 19:04 hhimanshu

I'm doing transition to Github Actions and this error

Run bahmutov/npm-install@v1
running npm-install GitHub Action
trying to restore cached NPM modules
Error: Cache service responded with 429
    at Object.<anonymous> (/home/runner/work/_actions/bahmutov/npm-install/v1/dist/index.js:3503:19)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/bahmutov/npm-install/v1/dist/index.js:3427:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Cache service responded with 429

shows up more than often. I feel that in case of reading the cache it should fallback with installing the dependency, not fail the build, right?

pjakubczyk avatar Apr 21 '21 08:04 pjakubczyk

I'm getting this error when the event is deployment, is this is because in some events because of the absence of some parameter retrieving cache is not possible? 🤔

anshulsahni avatar Nov 17 '21 13:11 anshulsahni

@anshulsahni I'm hitting the same thing as you in a deployment workflow. I think you are correct, it's not meant for that flow and likely something is missing. I'd say it's best to just run the install manually until then.

nickofthyme avatar Jan 27 '22 16:01 nickofthyme

Just got this error now: Error: getCacheEntry failed: Cache service responded with 503 from the setup-java@v2 action. Failed again when I retried. 503 suggests this is a problem with GitHub Actions, not with my workflow.

fransf-wtax avatar Jun 13 '22 07:06 fransf-wtax

Can there be a failover so that if the Cache fails to be retrieved, the standard npm install command gets executed instead. This will be able to still run the job if github actions have issues with caches.

nbonavia avatar Jun 13 '22 07:06 nbonavia

Just got this error now: Error: getCacheEntry failed: Cache service responded with 503 from the setup-java@v2 action. Failed again when I retried. 503 suggests this is a problem with GitHub Actions, not with my workflow.

Me too, but with setup-node@v2 for 16.x

Found in cache @ /opt/hostedtoolcache/node/16.15.1/x64
/opt/hostedtoolcache/node/16.15.1/x64/bin/npm config get cache
/home/runner/.npm
Error: getCacheEntry failed: Cache service responded with 503

14.x works great: Found in cache @ /home/ghrunner/actions-runner/_work/_tool/node/14.18.2/x64

UPD: See a workaround below: https://github.com/bahmutov/npm-install/issues/80#issuecomment-1153608979

afrokick avatar Jun 13 '22 08:06 afrokick

Yeah all my actions are failing now, too...

perrin4869 avatar Jun 13 '22 08:06 perrin4869

Same here What's going on? We have production build failed, which is critical

dannyk03 avatar Jun 13 '22 08:06 dannyk03

same here https://github.com/kiegroup/kogito-docs/runs/6857322733?check_suite_focus=true

Ginxo avatar Jun 13 '22 08:06 Ginxo

Me too, but with setup-node@v2 for 16.x

Found in cache @ /opt/hostedtoolcache/node/16.15.1/x64
/opt/hostedtoolcache/node/16.15.1/x64/bin/npm config get cache
/home/runner/.npm
Error: getCacheEntry failed: Cache service responded with 503

14.x works great: Found in cache @ /home/ghrunner/actions-runner/_work/_tool/node/14.18.2/x64

[For NodeJS] So, I had an investigation. It doesn't work if cache was enabled. Try to disable cache by commenting cache key in your job.

Warning: It'll slowdown your action. It is just temporary solution!!!

jobs:
  check-format:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js 16.x
        uses: actions/setup-node@v2
        with:
          node-version: 16.x
#          cache: 'npm'   <--- Action works only if cache disabled.
      - run: npm i
      - name: Check format
        run: npm run check-format
      - name: Linting
        run: npm run lint

afrokick avatar Jun 13 '22 08:06 afrokick

It wasn't working for me 5min ago (503 error), I retried now and it's working

Tonio-lavanda avatar Jun 13 '22 08:06 Tonio-lavanda

same here, looks like a github failure ...

yatuvy avatar Jun 13 '22 08:06 yatuvy

Me too, but with setup-node@v2 for 16.x

Found in cache @ /opt/hostedtoolcache/node/16.15.1/x64
/opt/hostedtoolcache/node/16.15.1/x64/bin/npm config get cache
/home/runner/.npm
Error: getCacheEntry failed: Cache service responded with 503

14.x works great: Found in cache @ /home/ghrunner/actions-runner/_work/_tool/node/14.18.2/x64

[For NodeJS] So, I had an investigation. It doesn't work if cache was enabled. Try to disable cache by commenting cache key.

Warning: It'll slowdown your action. It is just temporary solution!!!

jobs:
  check-format:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js 16.x
        uses: actions/setup-node@v2
        with:
          node-version: 16.x
#          cache: 'npm'   <--- Action works only if cache disabled.
      - run: npm i
      - name: Check format
        run: npm run check-format
      - name: Linting
        run: npm run lint

This worked for me, thanks @afrokick

mnicol93 avatar Jun 13 '22 08:06 mnicol93

I was also facing the same issue , I checked the github repo for the actions/setup-node and found out they have release a v3 upgrade . So i changed my code to use actions/setup-node@v3

and now its working 👍🏻 ..

May be you guys also try this method . And also its good practice to keep upgrading the version of the github action step

IamViditAgarwal avatar Jun 13 '22 08:06 IamViditAgarwal

I was also facing the same issue , I checked the github repo for the actions/setup-node and found out they have release a v3 upgrade . So i changed my code to use actions/setup-node@v3

and now its working 👍🏻 ..

May be you guys also try this method . And also its good practice to keep upgrading the version of the github action step

Run actions/setup-node@v3
Found in cache @ /home/ghrunner/actions-runner/_work/_tool/node/16.15.1/x64
/home/ghrunner/actions-runner/_work/_tool/node/16.15.1/x64/bin/npm config get cache
/home/ghrunner/.npm
Error: getCacheEntry failed: Cache service responded with 503

Just tried, doesn't work for v3. Only works with disabled cache.

afrokick avatar Jun 13 '22 08:06 afrokick

Yep, facing issue with cache: 'npm' but removing it fixes it...

      ....
      - name: Setup node env 📦
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node }}
          check-latest: true
-          cache: 'npm' 
      ....

vinayakkulkarni avatar Jun 13 '22 08:06 vinayakkulkarni

We're facing the same issue.

Error: getCacheEntry failed: Cache service responded with 503
- name: Install Node Deps
  uses: bahmutov/npm-install@v1

No cache key is specified.

TaenFN avatar Jun 13 '22 08:06 TaenFN

Same issue here

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

Ulset avatar Jun 13 '22 09:06 Ulset

I added the following to my package.json

"resolutions": {
    "@types/react": "17.0.14",
    "@types/react-dom": "17.0.14"
  }

worked for me :)))

how is it related to cache issue?

lossless1 avatar Jun 13 '22 09:06 lossless1

@lossless1 it's probably invalidating the cache

riffraff avatar Jun 13 '22 09:06 riffraff

They just returned server back alive. It works without any changes in the codebase

DonGriffon1 avatar Jun 13 '22 09:06 DonGriffon1

still not working reliably

TheFlow0360 avatar Jun 13 '22 09:06 TheFlow0360

We're experiencing the same issue Screenshot 2022-06-13 at 12 43 39 This fails randomly, re-running job helps (sometimes)

bel0v avatar Jun 13 '22 09:06 bel0v

Cache problem still existing. Also CloudFront Distribution is in "deploying" for 2h and in my prod. system the user auth is failing..

titushartm avatar Jun 13 '22 10:06 titushartm

actions/setup-java@v3 worked for my java project

yras5869 avatar Jun 13 '22 10:06 yras5869

Getting the same error here for actions/setup-node@v2

ChristianBell1995 avatar Jun 13 '22 10:06 ChristianBell1995