PNPM cache not working on Workers build

Have not been able to make caching work for pnpm in workers build. Couple of issues I found: Confusing docs: - looking at the docs it states that the caching folder for pnpm is .pnpm-store - When outputting the location using pnpm store path it says it is /opt/buildhome/.local/share/pnpm/store/v3 Forcing a location still downloads files Tried debugging it by: - Setting SKIP_DEPENDENCY_INSTALL true (I can see it working) - Set manually a cache location pnpm config set store-dir ~/.pnpm-store (Validated it is set with an echo before and after) - Set script to manually install Manually run pnpm install --prefer-offline
- Blasted the build cache - Run a couple of builds to populate cache. I'd expect the output of CI to be something like: - Progress: resolved 2476, reused 2459, downloaded 0, added 2476, done (Notice the downloaded 0) - Still seeing:
10:19:31.321 ../.. | Progress: resolved 2488, reused 0, downloaded 2393, added 2380
10:19:32.322 ../.. | Progress: resolved 2488, reused 0, downloaded 2406, added 2395
10:19:33.322 ../.. | Progress: resolved 2488, reused 0, downloaded 2469, added 2470
10:19:34.036 ../.. | Progress: resolved 2488, reused 0, downloaded 2471, added 2488, done
10:19:31.321 ../.. | Progress: resolved 2488, reused 0, downloaded 2393, added 2380
10:19:32.322 ../.. | Progress: resolved 2488, reused 0, downloaded 2406, added 2395
10:19:33.322 ../.. | Progress: resolved 2488, reused 0, downloaded 2469, added 2470
10:19:34.036 ../.. | Progress: resolved 2488, reused 0, downloaded 2471, added 2488, done
- Even when running this a couple of time with the same build-command Not sure what heuristic is used for caching (I imagine pnpm-lock.yaml ? Would be great to know that πŸ™ ) No build system options on workers setting - On the docs, I see a section for v2 to v3 Migration (here) - Thought this might be the case. But could not find that option anywhere on my workers. ---- FWIW ...I'm using this in a mono-repo setup with a pnpm-workspace.yaml file
28 Replies
ac
acβ€’6mo ago
Following this -- we are also using a pnpm workspace for our Workers and having the same issue (I see a Failed to restore dependencies from build cache. Skipping. at the start of each build, even though it says it saves them at the end of each build
fforres
fforresOPβ€’6mo ago
I think package dependencies and build dependencies are treated differently from what I understand. JIC you are using something like... remix/react-router It does not provide a cacheable build output as opposed to other frameworks
ac
acβ€’6mo ago
Oh, yeah you're right, so I guess that message is unrelated. Still seeing the same behavior as you with "reused 0" on all the dependencies (on top of it not filtering so it installs everything πŸ™ƒ)
Vero
Veroβ€’6mo ago
I've raised this internally
Maximo
Maximoβ€’6mo ago
Hi @fforres πŸ‘‹! Would it be possible for you to provide your build uuid? It'll be in your address bar like so .../production/builds/<build-uuid>
JohnDotAwesome
JohnDotAwesomeβ€’6mo ago
@Maximo we should update the docs. We use the default store dir on linux which is ~/.local/share/pnpm/store
fforres
fforresOPβ€’6mo ago
For sure, I have a couple of em. @Maximo 28c914ff-be0d-4f77-bb59-4c94ec9118bf This one is skipping dependency install. (And Setting the store-dir to ~/.pnpm-store) Question @JohnDotAwesome . Does this only cache on the default pnpm store dir? Or if I change it, it uses the updated folder?) (And if so, I'd be very curious on the heursitics... does it generate a cache per branch? Does it have a series of "nested" keys like github's action?) If it helps, I just run a test with default store-dir. Made a couple of CI runs with this command This is a run with it db8ee2d9-2507-4e24-bf54-af0a5845acb7
printenv && \
ls -al /opt/buildhome/.local/share/pnpm/store/v3/files && \
pnpm store path && \
ls -al /opt/buildhome/.local/share/pnpm/store/v3/files && \
pnpm install --prefer-offline --frozen-lockfile && \
NODE_OPTIONS='--max-old-space-size=7200' npx vite build --mode staging
printenv && \
ls -al /opt/buildhome/.local/share/pnpm/store/v3/files && \
pnpm store path && \
ls -al /opt/buildhome/.local/share/pnpm/store/v3/files && \
pnpm install --prefer-offline --frozen-lockfile && \
NODE_OPTIONS='--max-old-space-size=7200' npx vite build --mode staging
(With SKIP_DEPENDENCY_INSTALL true) On both ls, i'm able to see the files there πŸ™‚ But the progress still shows downloaded fields on subsequent runs
08:31:44.527 ../.. | Progress: resolved 1, reused 0, downloaded 0, added 0
08:31:45.179 ../.. | +2489 ++++++++++++++++++++++++++++
08:31:45.542 ../.. | Progress: resolved 2489, reused 0, downloaded 0, added 0
08:31:46.673 ../.. | Progress: resolved 2489, reused 1, downloaded 0, added 0
08:31:47.748 ../.. | Progress: resolved 2489, reused 2, downloaded 0, added 0
08:31:49.470 ../.. | Progress: resolved 2489, reused 3, downloaded 0, added 0
08:31:51.307 ../.. | Progress: resolved 2489, reused 3, downloaded 1, added 0
08:31:52.312 ../.. | Progress: resolved 2489, reused 3, downloaded 9, added 0
08:31:53.318 ../.. | Progress: resolved 2489, reused 3, downloaded 58, added 36
08:31:54.319 ../.. | Progress: resolved 2489, reused 3, downloaded 90, added 73
08:31:55.321 ../.. | Progress: resolved 2489, reused 3, downloaded 116, added 96
08:31:56.321 ../.. | Progress: resolved 2489, reused 3, downloaded 137, added 122
08:31:57.323 ../.. | Progress: resolved 2489, reused 3, downloaded 167, added 147
08:31:58.325 ../.. | Progress: resolved 2489, reused 3, downloaded 254, added 243
08:31:59.326 ../.. | Progress: resolved 2489, reused 3, downloaded 289, added 285
08:31:44.527 ../.. | Progress: resolved 1, reused 0, downloaded 0, added 0
08:31:45.179 ../.. | +2489 ++++++++++++++++++++++++++++
08:31:45.542 ../.. | Progress: resolved 2489, reused 0, downloaded 0, added 0
08:31:46.673 ../.. | Progress: resolved 2489, reused 1, downloaded 0, added 0
08:31:47.748 ../.. | Progress: resolved 2489, reused 2, downloaded 0, added 0
08:31:49.470 ../.. | Progress: resolved 2489, reused 3, downloaded 0, added 0
08:31:51.307 ../.. | Progress: resolved 2489, reused 3, downloaded 1, added 0
08:31:52.312 ../.. | Progress: resolved 2489, reused 3, downloaded 9, added 0
08:31:53.318 ../.. | Progress: resolved 2489, reused 3, downloaded 58, added 36
08:31:54.319 ../.. | Progress: resolved 2489, reused 3, downloaded 90, added 73
08:31:55.321 ../.. | Progress: resolved 2489, reused 3, downloaded 116, added 96
08:31:56.321 ../.. | Progress: resolved 2489, reused 3, downloaded 137, added 122
08:31:57.323 ../.. | Progress: resolved 2489, reused 3, downloaded 167, added 147
08:31:58.325 ../.. | Progress: resolved 2489, reused 3, downloaded 254, added 243
08:31:59.326 ../.. | Progress: resolved 2489, reused 3, downloaded 289, added 285
JohnDotAwesome
JohnDotAwesomeβ€’6mo ago
We only detect specific directories to cache. So changing it to a custom directory will not work
fforres
fforresOPβ€’6mo ago
Gotcha, πŸ™‚
JohnDotAwesome
JohnDotAwesomeβ€’6mo ago
I'm going to have to continue looking into this tomorrow. I apologize for the issues here!
fforres
fforresOPβ€’6mo ago
Appreciate it @JohnDotAwesome πŸ™
JohnDotAwesome
JohnDotAwesomeβ€’6mo ago
I've got to be missing something. I fixed pnpm caching last week. I have a personal project that uses pnpm workspaces and caching is working fine on that repo. Although, pnpm install is so damn fast, caching hardly makes a difference anyway Oh actually there it is... the extract cache is failing for you. Interesting... @fforres just double checking - have you tried clearing the cache for your builds yet?
fforres
fforresOPβ€’6mo ago
Yes I have, will try again on new run. Is the cache scoped per-branch/branch/etc? I assume it hashes the package files, but aside from that, wondering if there's anything else to consider @JohnDotAwesome ? πŸ€”
JohnDotAwesome
JohnDotAwesomeβ€’6mo ago
Cache will effectively be scoped per worker. The key is computed from your project's lockfile, so it can be shared between branches Something about your cache store is breaking our extraction process. I'm trying to reproduce it on my own repo now
fforres
fforresOPβ€’6mo ago
Did a new run πŸ™‚ - Cleared cache - First run here: 8f951107-26a3-438a-8449-ca22946d3198 (Downloaded packages. Saw the Uploading to dependency cache at the end) - Re-run here 3144e5fb-3639-49f0-a6f2-7cdd2739a631 says (Failed to restore dependencies from build cache. Skipping) (Org ID: b75ee9798c9c48a874af240b29724270 in case it helps) got a mono-repo with a few sub projects (11) Aside from that ... i don't think we have something custom. Could it be that we did a few changes to the .npmrc file? I made some updates to speedup codex a bit ago πŸ€”
@tiptap-pro:registry=https://registry.tiptap.dev/
//registry.tiptap.dev/:_authToken=OUR_TOKEN
public-hoist-pattern[]=*drizzle*
network-concurrency=32
maxsockets=96
prefer-offline=true
@tiptap-pro:registry=https://registry.tiptap.dev/
//registry.tiptap.dev/:_authToken=OUR_TOKEN
public-hoist-pattern[]=*drizzle*
network-concurrency=32
maxsockets=96
prefer-offline=true
I don't think it should affect, bu JIC
JohnDotAwesome
JohnDotAwesomeβ€’6mo ago
Unlikely... But we'll see πŸ™‚
fforres
fforresOPβ€’6mo ago
hey @JohnDotAwesome ! RE: ping on this πŸ™ Is there any way I can help? Happy to jump on a call/give you acess to our repo, or anything Also, I know you mentioned:
I have a personal project that uses pnpm workspaces and caching is working fine on that repo.
Is that public? Would love to compare setups maybe I'm missing something πŸ™
Happy to help in any way
JohnDotAwesome
JohnDotAwesomeβ€’6mo ago
Hey @fforres apologies I had to shift focus. Jumping on a call would be great. I’ll DM you
fforres
fforresOPβ€’4mo ago
πŸ‘‹ not sure if you've been able to see this? Still seeing issues 😦 πŸ‘‹ @JohnDotAwesome ? πŸ™ Or @Vero πŸ™ maybe? πŸ™ In case it helps: Our organization id is: b75ee9798c9c48a874af240b29724270 and a recent run build-id that did not picked up a cache: 0adf3706-5b8f-49fb-a004-65f8cdfd8bd5 Some more context on this. Another thing on why we are looking into have pnpm cache working, is that we usually see timeouts on the pnpm registry for some package installations, that made our builds to increase on 30+ seconds, or more for example when they fail more than once.
09:38:23.500  WARN  GET https://registry.npmjs.org/@opentelemetry/instrumentation-socket.io/-/instrumentation-socket.io-0.48.0.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.535  WARN  GET https://registry.npmjs.org/@opentelemetry/instrumentation-tedious/-/instrumentation-tedious-0.20.0.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.540  WARN  GET https://registry.npmjs.org/@opentelemetry/resource-detector-alibaba-cloud/-/resource-detector-alibaba-cloud-0.31.3.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.541  WARN  GET https://registry.npmjs.org/@opentelemetry/resource-detector-azure/-/resource-detector-azure-0.8.0.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.541  WARN  GET https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.0.1.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.500  WARN  GET https://registry.npmjs.org/@opentelemetry/instrumentation-socket.io/-/instrumentation-socket.io-0.48.0.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.535  WARN  GET https://registry.npmjs.org/@opentelemetry/instrumentation-tedious/-/instrumentation-tedious-0.20.0.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.540  WARN  GET https://registry.npmjs.org/@opentelemetry/resource-detector-alibaba-cloud/-/resource-detector-alibaba-cloud-0.31.3.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.541  WARN  GET https://registry.npmjs.org/@opentelemetry/resource-detector-azure/-/resource-detector-azure-0.8.0.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
09:38:23.541  WARN  GET https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.0.1.tgz error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
wojtodzio
wojtodzioβ€’2mo ago
We seem to also be getting hit by this, i.e., we see "Failed to restore dependencies from build cache. Skipping." on each build
johtso
johtsoβ€’2mo ago
We also experience the same behaviour, pnpm monorepo, build command pnpm install --frozen-lockfile Org id: 814e8d36e1399315694670071a13c144 Build id: 5146c938-7a2e-45d5-9ac0-3930b9e1eabf
11:20:43.963 Restoring from dependencies cache
11:20:43.965 Restoring from build output cache
11:20:45.086 Detected the following tools from environment: pnpm@10.12.4, nodejs@22.16.0
11:20:53.999 Failed to restore dependencies from build cache. Skipping.
11:21:11.882 Installing project dependencies: pnpm install --frozen-lockfile
11:20:43.963 Restoring from dependencies cache
11:20:43.965 Restoring from build output cache
11:20:45.086 Detected the following tools from environment: pnpm@10.12.4, nodejs@22.16.0
11:20:53.999 Failed to restore dependencies from build cache. Skipping.
11:21:11.882 Installing project dependencies: pnpm install --frozen-lockfile
texan
texanβ€’2mo ago
πŸ‘‹ hey folks! I've escalated to the Builds team for them to look into this again. Thanks for letting us know!
Jacob
Jacobβ€’2mo ago
Hey folks! I took a look at this today and got a fix ready and will ship monday. Confirmed cache restore worked on a pnpm monorepo with 3k deps. Thank you for your patience πŸ™
johtso
johtsoβ€’2mo ago
awesome! I guess it's still yet to be deployed as I see the same behaviour. Do give us a shout when it goes live!
Jacob
Jacobβ€’2mo ago
Yep sorry about that - getting it shipped today for sure and will let you know! this went out yesterday afternoon btw! Lmk if you still see any issues
johtso
johtsoβ€’2mo ago
awesome! Interestingly, hasn't made builds any faster.. I guess the download speeds are fast enough for it not to really matter.. (although it does avoid the occasional npm registry connection timeout)
Jacob
Jacobβ€’2mo ago
Yeah, pnpm documents that caching may not actually speed things up unfortunately https://pnpm.io/continuous-integration
No description
Jacob
Jacobβ€’2mo ago
re: timeouts - we have some changes releasing soon that should make certain network requests more reliable, so hopefully we will see fewer issues with npm like that

Did you find this page helpful?