Yarn installed during every build

Hi!

For some reason every build results in reinstalling yarn from scratch.
Previously install took ~1second

6:44:31 PM: Started restoring cached node modules
6:44:31 PM: Finished restoring cached node modules
6:44:31 PM: Started restoring cached yarn cache
6:44:31 PM: Finished restoring cached yarn cache
6:44:31 PM: Installing NPM modules using Yarn version 1.22.4
6:44:32 PM: yarn install v1.22.4
6:44:32 PM: [1/4] Resolving packages...
6:44:33 PM: success Already up-to-date.
6:44:33 PM: Done in 1.00s.
6:44:33 PM: NPM modules installed using Yarn
6:44:33 PM: Started restoring cached go cache
6:44:33 PM: Finished restoring cached go cache

Now it takes more than hundred seconds.

4:12:53 PM: Started restoring cached node modules
4:12:53 PM: Finished restoring cached node modules
4:12:53 PM: Started restoring cached yarn cache
4:12:53 PM: Finished restoring cached yarn cache
4:12:53 PM: Installing yarn at version 1.22.4
4:12:53 PM: Installing Yarn!
4:12:53 PM: > Downloading tarball...
4:12:53 PM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.pn3oIdf6fA
...
4:14:46 PM: [4/4] Building fresh packages...
4:15:09 PM: Done in 133.40s.
4:15:09 PM: NPM modules installed using Yarn
4:15:10 PM: Started restoring cached go cache
4:15:10 PM: Finished restoring cached go cache

No changes in CircleCI were made, also in netlify.toml I did just minor fixes adding path rewrite. Nothing affecting build process.

Could you please suggest where to look or how to fix it?
I’m running out of ideas why this is happening.

Hi, @ianbrode. The first set of logs show nothing being installed by yarn. The second set of logs shows many packages being installed (or at least it seems so as the logs are deleted for that section above).

Are these builds occurring in CircleCI or at Netlify? If they are at Netlify would you please send me the deploy ids for the two builds above?

If they are at CircleCI, how are you building there? Would you be willing to send us the the complete logs for those builds?

Hi, @luke!

Builds occur in Netlify.

6:44:32 PM: [1/4] Resolving packages...
Actually this is installation of packages from cache. Build id: 5f7b3f49577052000785639d

In second example the yarn itself is being installed. And after that whole bunch of packages are installed from network, not from cache. Build id: 5fbd05bba4eec90008735e66

Thank you in advance for help!

Hi, @ianbrode. I see exactly what you are talking about and there is an explanation.

I’m showing that the production branch for the site in question changed on 2020-11-22. However, no build happened for the “new production branch” (more about the quotes below) until after the build you sent first.

Why the quotes? Because this is a branch which was built for this site previously. It was, therefore, not a new branch but the production branch did change.

The change of the production branch forced the existing production build cache to be expired. These deploy previews therefore had no cache to load so they were installing dependencies without any cache.

When the production branch was finally built again, subsequent deploy previews began using the cache because it existed again.

The first production branch deploy after the change was deploy id 5fbd45aea9476f0007049a56 which happened at 9:41 AM PST. The next deploy preview at 10:39 AM (id 5fbd53693391520007c58b9c) then shows the yarn install using the cache.

The workaround to avoid having a missing cache for deploy previews is to always trigger a build after changing the production branch for a site. Note, a build must be successful before we will safe the cache.

I hope this clarifies the issue. If there are other questions though, please let us know.