Skip to content

Ignore cache misses prior to fetch step to allow mode=update-lockfile#7176

Open
ReDrUm wants to merge 1 commit into
yarnpkg:masterfrom
ReDrUm:fix-cache-misses
Open

Ignore cache misses prior to fetch step to allow mode=update-lockfile#7176
ReDrUm wants to merge 1 commit into
yarnpkg:masterfrom
ReDrUm:fix-cache-misses

Conversation

@ReDrUm
Copy link
Copy Markdown
Contributor

@ReDrUm ReDrUm commented Jun 4, 2026

What's the problem this PR addresses?

In some situations yarn can fail with an ENOENT error if a cache miss occurs during a yarn --mode=update-lockfile invocation where it should be inconsequential.

$ yarn --mode update-lockfile
➀ YN0000: · Yarn 4.16.0-dev
➀ YN0000: β”Œ Project validation
➀ YN0000: β”” Completed
➀ YN0000: β”Œ Resolution step
➀ YN0000: β”” Completed in 2m 59s
➀ YN0000: β”Œ Fetch step
➀ YN0001: β”‚ Error: ENOENT: no such file or directory, stat '/path/to/my-project/.yarn/cache/xlsx-https-15979b9f23-895c589c5f.zip'
➀ YN0000: β”” Completed in 0s 540ms
➀ YN0000: · Failed with errors in 2m 59s

The ENOENT error is thrown by Yarn after it records a cache miss and then tries to stat the expected cache file in https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Project.ts#L1174

Project.fetchEverything was reusing the whole report.cacheMisses set and trying to stat the local cache even for misses that happened before the fetch step and never wrote into .yarn/cache.

How did you fix it?

Revise the Project to track the cache misses and ignore misses prior to the fetch step.

Tested on my local project which was affected by the issue, and overcame it with these changes.

Example of affected entry:

"xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz":
  version: 0.20.3
  resolution: "xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
  bin:
    xlsx: ./bin/xlsx.njs
  checksum: 10/895c589c5f6ffc665184165b5aa5d337de0e2ee24ccd53d517d2378f3a8a7df82405b023fdcfde9f49d7de3d4ef1622cf2ef145316c9732c634a86ee313bad4f
  languageName: node
  linkType: hard

Checklist

  • [ x ] I have set the packages that need to be released for my changes to be effective.
  • [ x ] I will check that all automated PR checks pass before the PR gets reviewed.

@ReDrUm ReDrUm force-pushed the fix-cache-misses branch from 00e2958 to 25dd234 Compare June 4, 2026 05:32
@ReDrUm ReDrUm force-pushed the fix-cache-misses branch from 25dd234 to 6342037 Compare June 4, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant