CI Fails randomly (cache problem?)

I have created nice I think script for CI.
So it only does npm install when package.json changes.

other than that it does lint script and build script from cache.
But occasionally I get error that looks like cache wasn’t properly loaded?
If I do retry sometimes more than once, it works eventually. Why is this happening ?


and script:

   install:
  stage: install
  tags:
    - test
    - vuejs
  cache:
    untracked: true
    key: one-key-to-rule-them-all
    paths:
      - node_modules/
      - package-lock.json
  script:
    - rm package-lock.json || true
    - npm install
  only:
    refs:
      - merge_requests
    changes:
      - package.json
  
lint:
  stage: lint
  tags:
    - test
    - vuejs
  cache:
    untracked: true
    key: one-key-to-rule-them-all
    paths:
      - node_modules/
      - package-lock.json
    policy: pull
  script:
    - npm run lint
    - npm run lint:css
  only:
    - merge_requests

Hello @uneasy & welcome to our forums :wave:

If you can reproduce the problem, please feel free to send us more info or even a demo project to investigate further. Off the top of my head, I would recommend applying one of the advice posted in

Does that help you move forward?