bahmutov / npm-install

GitHub Action for install npm dependencies with caching without any configuration
https://github.com/marketplace/actions/npm-or-yarn-install-with-caching
652 stars 71 forks source link

Error: getCacheEntry failed: Cache service responded with 503 #80

Open gr2m opened 3 years ago

gr2m commented 3 years ago

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?

bitttttten commented 3 years ago

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
jgoux commented 3 years ago

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

aryella-lacerda commented 3 years ago

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 }}
hhimanshu commented 3 years ago

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

pjakubczyk commented 3 years ago

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?

anshulsahni commented 2 years ago

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? πŸ€”

nickofthyme commented 2 years ago

@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.

fransf-wtax commented 2 years ago

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.

nbonavia commented 2 years ago

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.

afrokick commented 2 years ago

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

perrin4869 commented 2 years ago

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

dannyk03 commented 2 years ago

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

Ginxo commented 2 years ago

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

afrokick commented 2 years ago

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
Tonio-lavanda commented 2 years ago

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

yatuvy commented 2 years ago

same here, looks like a github failure ...

mnicol93 commented 2 years ago

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

IamViditAgarwal commented 2 years ago

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

afrokick commented 2 years ago

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.

vinayakkulkarni commented 2 years ago

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' 
      ....
TaenFN commented 2 years ago

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.

Ulset commented 2 years ago

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
lossless1 commented 2 years ago

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?

riffraff commented 2 years ago

@lossless1 it's probably invalidating the cache

DonGriffon1 commented 2 years ago

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

TheFlow0360 commented 2 years ago

still not working reliably

bel0v commented 2 years ago

We're experiencing the same issue

Screenshot 2022-06-13 at 12 43 39

This fails randomly, re-running job helps (sometimes)

titushartm commented 2 years ago

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

yras5869 commented 2 years ago

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

ChristianBell1995 commented 2 years ago

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

sdsa-cci commented 2 years ago
##[debug]getCacheEntry - Attempt 2 of 2 failed with error: Cache service responded with 503
Error: getCacheEntry failed: Cache service responded with 503

Getting this issue from past 10 mins now.

kimjngyun commented 2 years ago

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

Attempting to download 17.x...
Not found in manifest.  Falling back to download directly from Node
Acquiring 17.[9](https://github.com/kimjngyun/kimjngyun.github.io/runs/6859207416?check_suite_focus=true#step:3:10).1 - x64 from https://nodejs.org/dist/v17.9.1/node-v17.9.1-linux-x64.tar.gz
Extracting ...
/usr/bin/tar xz --strip 1 --warning=no-unknown-keyword -C /home/runner/work/_temp/42346de7-0551-426c-8ac4-088aec477c41 -f /home/runner/work/_temp/171d2419-fa2c-464b-8235-cca6d234c4bc
Adding to the cache ...
Done
/usr/local/bin/yarn --version
1.22.18
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
Error: getCacheEntry failed: Cache service responded with 503
akindo commented 2 years ago

Updating to Checkout v. 3 didn't help. Didn't try updating setup-node to v. 3, but disabling npm cache did the trick.

dmarinere commented 2 years ago

Updating to Checkout v. 3 didn't help. Didn't try updating setup-node to v. 3, but disabling npm cache did the trick.

How do I disable cache

yras5869 commented 2 years ago

Disable the cache. It should work

afrokick commented 2 years ago

Updating to Checkout v. 3 didn't help. Didn't try updating setup-node to v. 3, but disabling npm cache did the trick.

How do I disable cache

Read above.

https://github.com/bahmutov/npm-install/issues/80#issuecomment-1153608979

dmarinere commented 2 years ago

Updating to Checkout v. 3 didn't help. Didn't try updating setup-node to v. 3, but disabling npm cache did the trick.

How do I disable cache

Read above.

#80 (comment)

Thank you

sm1990 commented 2 years ago

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

I have setup-node@v3 and still got the issue. Commenting cache:npm worked for me.

sdsa-cci commented 2 years ago

No need to upgrade anything. Just re-run you failed jobs. I tried this and worked for me. Seems like it was a service issues from Github's side.

topleft1562 commented 2 years ago

still failing for me.

kudaleganesh commented 2 years ago

Disabling the cache:npm works for me.

sirJiggles commented 2 years ago

are you all turning the cache on again and it works after? as I don't really want to just "turn off the cache" ideally πŸ™ˆ

christos97 commented 2 years ago

Yes disabling (commenting out) the cache works.

It's not about the setup-* version.

Re-running failed jobs may work (tested) but it's not reliable.

If you HAVE to release today, just remove the cache but they will get it to work eventually I guess.

The thing here is, we need a way to disable cache without commiting t master branch imho if the cache action is un-reliable.

Is this happening because of the underlying actions/cache action?

If so we need to know, we use actions/cache to cache angular build files too.

mateoqac commented 2 years ago

Ruby budnle-cache is failing too! :(

kudaleganesh commented 2 years ago

are you all turning the cache on again and it works after? as I don't really want to just "turn off the cache" ideally πŸ™ˆ

After turning the cache on again, it failed. It is a temp solution.

kudaleganesh commented 2 years ago

It is a service issue. https://www.githubstatus.com/

stdimitrovv commented 2 years ago

No production releases today, boys πŸ˜ƒ

mwmw7 commented 2 years ago

Oh my god... We have to do hotfix...our team is still wating

Indronil commented 2 years ago

Hi,

I am having the same issue in my CI system just started occurring today for the first time. It was working fine without any issue until Friday.

Run actions/setup-node@v2 Found in cache @ /opt/hostedtoolcache/node/14.19.3/x64 /usr/local/bin/yarn --version 1.22.18 /usr/local/bin/yarn cache dir /home/runner/.cache/yarn/v6 Error: getCacheEntry failed: Cache service responded with 503

Is it an issue from github side and will it be solved soon? We can live without cache until then if that is the case?

afrokick commented 2 years ago

Hi,

I am having the same issue in my CI system just started occurring today for the first time. It was working fine without any issue until Friday.

Run actions/setup-node@v2 Found in cache @ /opt/hostedtoolcache/node/14.19.3/x64 /usr/local/bin/yarn --version 1.22.18 /usr/local/bin/yarn cache dir /home/runner/.cache/yarn/v6 Error: getCacheEntry failed: Cache service responded with 503

Is it an issue from github side and will it be solved soon? We can live without cache until then if that is the case?

Yes, just disable cache for some time while Github fixing this issue