As the Test Platform team, we are trying to understand why npm cache keeps getting corrupted. This is an explainer of initial findings as we try to understand the problem, have a discussion around it, and solve it for good.
What happens
A castor save can start rsyncing a workspace cache to the central instance, and then have that workspace deleted underneath it while the rsync is still running. The rsync fails partway through, but it has already been changing the live central cache, so what is left published is an npm _cacache whose index-v5 entries reference content-v2 blobs that no longer exist.
npm ci does not treat a missing content blob as a cache miss. It fails with ENOENT. So every build that loads that namespace afterwards dies at npm install, and keeps dying until something happens to rewrite the cache. On 2026-09-15 that was 3h21m.
The ordering, expected versus actual
This is the main issue,
Expected. The post-build publishers on a Quibble job run one after another:
1. npm cache verify
2. trigger castor-save-workspace-cache, and BLOCK until it finishes
-> save job rsyncs /srv/jenkins/workspace/<job>/cache
to /srv/castor/<namespace>
3. clear the workspace cache: find /cache -mindepth 1 -deleteStep 3 must not start before step 2 finishes. The only thing enforcing that is block: true on the trigger in jjb/castor.yaml, and the comment there says so explicitly:
- Must be blocking or the next publisher will kick in and delete the cache while it is being saved.
Actual, when the wait is interrupted.
1. npm cache verify
2. trigger castor-save-workspace-cache -> save job starts rsyncing
the blocking wait is interrupted
PostBuildScript turns it into PostBuildScriptException / FAILURE
step 2 gives up ... BUT THE SAVE JOB IS STILL RUNNING
3. clear runs NOW, deleting the directory the rsync is reading fromThe important detail is that the downstream save is a separate Jenkins build. Interrupting the wait does not stop the save. Step 2 returns, Jenkins proceeds to step 3, and the rsync loses its source mid-transfer.
The trace
Three builds, in order.
(a) The build whose wait was interrupted — quibble-with-gated-extensions-vendor-mysql-php83 #57281, console in log order:
npm cache verified less than a day ago, skipping npm cache verify [PostBuildScript] - [INFO] Executing post build scripts. Waiting for the completion of castor-save-workspace-cache castor-save-workspace-cache #6977607 started. [PostBuildScript] - [ERROR] An error occured during post-build processing. org.jenkinsci.plugins.postbuildscript.PostBuildScriptException: java.lang.InterruptedException at ...TriggerBuilder.perform(TriggerBuilder.java:175) ... + echo 'Clearing /srv/jenkins/workspace/quibble-with-gated-extensions-vendor-mysql-php83/cache' Clearing /srv/jenkins/workspace/quibble-with-gated-extensions-vendor-mysql-php83/cache
The clear publisher is build-on: SUCCESS, UNSTABLE, FAILURE, ABORTED, so the build being marked FAILURE does not stop it.
(b) The save that was still running — castor-save-workspace-cache #6977607, started by #57281:
Defined: CASTOR_NAMESPACE="castor-mw-ext-and-skins/master/quibble-with-gated-extensions-vendor-mysql-php83" Syncing cache From.. 172.16.18.155:/srv/jenkins/workspace/quibble-with-gated-extensions-vendor-mysql-php83/cache To.... /srv/castor/castor-mw-ext-and-skins/master/quibble-with-gated-extensions-vendor-mysql-php83 >>> Start: castor-save rsync directory has vanished: "/cache/npm/_cacache/index-v5/c7/da" file has vanished: "/cache/npm/_cacache/index-v5/59/ac/f997d249a439237f8cf4c9cdcd0734d9955ad7f28a426da82d329b36a9c4" [... 2551 more ...] Number of files: 17,690 (reg: 7,697, dir: 9,993) Number of created files: 0 Number of deleted files: 179 (reg: 179) Number of regular files transferred: 0 Total transferred file size: 0 bytes Literal data: 0 bytes rsync warning: some files vanished before they could be transferred (code 24) at main.c(1874) [generator=3.2.7] castor-save rsync failed (exit code 24) <<< Finish: Failed: castor-save rsync, in 6.113 s
2443 files and 110 directories vanished mid-transfer, 2437 of the files under index-v5 and 6 under content-v2.
The stats block is where the damage shows, and it is worth being precise about which part of rsync caused it. Zero files were transferred. 179 were deleted. That run copied nothing into the central cache, the only thing it did was delete 179 files from it.
rsync lists the source first, then makes the destination match that list. The workspace was being deleted while it was still listing, so 179 files came back missing from the list, and rsync read that as "these were removed on purpose" and deleted them from /srv/castor at the end of the transfer. The vanished warnings are a separate set, files that were in the list but already gone by the time rsync tried to read them.
This matters because it rules out the option you would reach for first. --delay-updates is already in use on the save, and it did not help:
- It only covers files being updated. The man page describes it as putting "the temporary file from each updated file into a holding directory until the end of the transfer". This transfer updated nothing. Deletions do not go through it at all, they go through --delete-delay, which computes them during the transfer and applies them to the live directory afterwards.
- Even for updates it is "renamed into place in rapid succession", which is N separate renames rather than one. The man page calls it "a little closer to atomic", not atomic, so an interruption during that rename burst would leave a partly updated tree.
Note the destination: the rsync writes and deletes straight into the live /srv/castor/<namespace>. A failed save does not mean the previous cache was kept.
Two further details from jjb/castor-save-workspacecache.bash that matter for what happens next:
- The generation counter is bumped before the rsync runs, so the damaged tree is published under a fresh generation and sibling builds that loaded the previous one skip their own save rather than overwriting it.
- The script's comment claims an interrupted save is safe because "a later build that loads this generation heals the content with its own full sync". That does not happen, see the next section.
(c) The next build in that namespace — #57349. The load reports success:
>>> Start: castor-load rsync Number of files: 17,691 (reg: 7,698, dir: 9,993) Total file size: 253,722,087 bytes <<< Finish: Success: castor-load rsync, in 4.414 s
Then:
npm warn tarball tarball data for which-typed-array@... seems to be corrupted. Trying again. npm warn tarball tarball data for @babel/core@... seems to be corrupted. Trying again. [... ~50 more ...] npm error code ENOENT npm error syscall stat npm error path /cache/npm/_cacache/content-v2/sha512/5d/36/6ce8c20b06a67a1498b9a60e667dd7baaf6a3432dedcad5b896a05ba6f3f3a4ccd8cfd93b11a007ac9ef922c1bce860b8d31a36db717b55f1f8cd67ab526 npm error enoent Invalid response body while trying to fetch https://registry.npmjs.org/test-exclude: ENOENT: no such file or directory <<< Failed: npm install in /workspace/src, in 41.395 s
The seems to be corrupted warnings are integrity mismatches, which npm retries past. The ENOENT is fatal.
Why the damage sticks for hours
Both the npm cache verify publisher and the castor save publisher are build-on: SUCCESS. A build that dies at npm install runs neither, so it never repairs or replaces the cache that killed it. The only builds that could rewrite the cache are exactly the builds the cache is breaking.
The way out is accidental, eventually a build whose dependency set happens to miss the damaged entries succeeds and saves a repaired cache. That is why 09-15 recovered at ~17:48 rather than never, and why recovery time looks arbitrary.
How to recognise it
The signature is distinctive, and worth knowing because the symptom appears on changes that have nothing to do with each other.
- A Quibble build fails with npm error code ENOENT and a path under /cache/npm/_cacache/content-v2/.
- Several unrelated repositories fail the same way, in the same job, within a short window. The castor namespace is castor-mw-ext-and-skins/<branch>/<job> for all extensions and skins, so the blast radius follows the job name, not the repo. On 09-14/15 it spanned 24 different extension repositories.
- Look at castor-save-workspace-cache builds shortly before the first failure, filtered to TRIGGERED_JOB_NAME = the failing job. Look for file has vanished and rsync ... (code 24).
- In the upstream build that triggered that save, look for PostBuildScriptException followed by Clearing ....
Two instances found this way:
2026-09-15, quibble-with-gated-extensions-vendor-mysql-php83. Save #6977607 failed at 14:27:01. Builds in that namespace, by hour:
| hour (UTC) | fail | succ |
|---|---|---|
| 13:00 | 0 | 19 |
| 14:00 | 14 | 11 |
| 15:00 | 13 | 2 |
| 16:00 | 8 | 8 |
| 17:00 | 5 | 5 |
| 18:00 | 1 | 6 |
2026-09-14, quibble-vendor-mysql-php83. Save failed at 21:03:43. Then, 33 seconds later:
| time | repo | build |
|---|---|---|
| 21:04:16 | mediawiki/extensions/GrowthExperiments | #111744 |
| 21:04:21 | mediawiki/extensions/WikiLambda | #111745 |
| 21:04:49 | mediawiki/extensions/InlineComments | #111746 |
Why it surfaced now
The race is not new, there were 48 npm install phase failures on 2026-08-29. What changed is that the thing quietly repairing the damage was throttled.
npm cache verify prunes index entries whose content is missing. It used to run on every gate-and-submit and postmerge build. It was throttled to once per day per cache on 2026-09-11, for good reasons (T437377): verifying on every build rewrote the whole index and made saves impossible to skip as unchanged.
Build #57281 logged exactly that, moments before triggering the save that broke the cache:
npm cache verified less than a day ago, skipping npm cache verify
npm install phase failures per day:
| date | failures |
|---|---|
| 2026-08-29 | 48 |
| 2026-09-03 | 7 |
| 2026-09-08 | 1 |
| 2026-09-14 | 11 |
| 2026-09-15 | 36 |
Impact
- 34 distinct changes affected on 09-14/15, 21 of them gate builds. Each was voted Verified-1 and dropped from the merge queue, requiring a full gate cycle to re-enter, with a Zuul reset for everything behind them.
- Separately, the same interrupted wait marks fully green builds as FAILURE: 25 to 51 builds per day in gate and postmerge are FAILURE with no Quibble phase reporting a failure. Tracked as T352319.