Skip to content

fix: a warmed npm worktree's Windows build is cached again - #6655

Merged
janicduplessis merged 2 commits into
mainfrom
fix/6633-windows-install-carry
Nov 29, 2026
Merged

janicduplessis merged 2 commits into
mainfrom
fix/6633-windows-install-carry

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

On Windows, a native build in a worktree warmed from an npm checkout is installed but never cached: both worktrees of the nightly android bare (loop, windows) lane print package-lock.json changed after the last install; the build will be installed but not cached, so worktree 2 cannot hit what worktree 1 built (#6634, #6628).

Two things combine:

  • Since fix: worktree warm keeps pnpm links on Windows #6472 (50ec9959e) the Windows carry copies node_modules with Node's fs.cp instead of MSYS cp -R (since feat: clone with cow-clone on macOS, Linux and Windows instead of a compiled helper #6550 that is the fallback after cow-clone, which on NTFS reports unsupported). fs.cp copies each file with copyFile, which on Windows keeps the source's last-write time, and a cow-clone on ReFS or a Dev Drive keeps it too. The carried node_modules/.package-lock.json now predates the package-lock.json git just checked out, so newerThanInstall no longer passes on time order and has to read the warmed-install record. Before, the copy stamped fresh times and the record was never needed on Windows, which is why the 2026-11-26 nightly (6ed3dd662) stored fine.
  • prepareInstallCarry writes that record only when the target's package.json, lockfile and patches hash the same as the source's. Git for Windows checks them out with CRLF (core.autocrlf=true on the runner image; the nightly log shows LF will be replaced by CRLF), while the source checkout's install read LF files. The digests never match, so the record is never written.

Solution

installInputDigest hashes each install input with CRLF folded to LF. A line-ending-only difference is git's conversion of the same committed blob, and npm, pnpm and yarn parse these files the same either way. Patch files are folded too: they come from the same blob, and the carried node_modules already holds what the source applied. The digest is only compared in memory during the warm; nothing on disk changes shape, and the fingerprint key is untouched.

I did not go back to fresh copy times. That would pass the gate by time order without checking the inputs at all.

Test plan

  • New CRLF checkout row in the cache gate checks the carried install with %s (worktree-warm.integration.test.ts): the target's package.json, lockfile and patch are multi-line CRLF versions of the source's LF files. It fails on main (the warning is printed) and passes with the fix, on every platform.
  • Windows, on a windows-debug.yml runner (NTFS D:, core.autocrlf=true from C:/Program Files/Git/etc/gitconfig): a git-committed npm fixture with LF package.json/package-lock.json and an older-stamped node_modules/.package-lock.json, then stim worktree add.
    • On main (19292c0): the worktree's package-lock.json is CRLF and written at checkout time, the carried .package-lock.json keeps the source's exact mtime (21:45:27.8054532), and no warmed-install.json is written.
    • On this branch: same layout, and workspaces\wt2--...\warmed-install.json is written.
    • All 15 rows of the cache gate checks the carried install with %s pass there, including matching inputs and CRLF checkout, which accept the carried install through the record on NTFS. Those rows never ran on Windows before; the second commit adds them to the Windows clone (ntfs) and clone (refs) lanes of the full suite.
  • Native E2E suite=loop, run on tmp/6633-e2e-with-6659 (this branch plus fix: pin cross-spawn 7.0.6, whose 7.1.0 breaks npm on Windows #6660, which the Windows fixture needs since cross-spawn 7.1.0), android bare (loop, windows) job 141156135471:
    • wt1 fingerprint a8677a.. miss, wt1 cold build: the restored cross-run cache held no matching fingerprint, launched;
    • wt2 fingerprint a8677a.. hit, cacheHit="local", CACHE PROOF: second worktree installed from cache without compiling, PASS bare-android;
    • no changed after the last install anywhere in the log.
      The first attempt of that job also printed no warning after its cold build, but failed STIM_LAUNCH_FAILED (monkey) on an emulator that took 12m48s to boot. The other loop lanes passed.

Fixes #6633. Refs #6634, #6628.

@janicduplessis janicduplessis added area: cli packages/stim-cli, including its README and guide ci-full run the macOS, Windows, Desktop and license jobs on this pull request area: docs docs/ and root documents labels Nov 28, 2026
@janicduplessis

Copy link
Copy Markdown
Collaborator Author

Native E2E suite=loop (run 46193153813, head 8880bb5): ios expo, ios bare, android bare and android expo loops pass. android bare (loop, windows) failed twice (job 141128374422 and rerun 141135406124) at the same point, before Stim runs: npx @react-native-community/cli@latest init ... --pm npm stops with Cannot find module 'D:\e\rncli-init-template-*\node_modules\npm\bin\npm-prefix.js'. The fixture step fails the same way both times, so it is a repeatable Windows fixture break, not a one-off, and the Windows end-to-end proof of this fix is still outstanding.

@janicduplessis
janicduplessis force-pushed the fix/6633-windows-install-carry branch from 2c2a24a to 7f0b328 Compare November 29, 2026 00:08
@janicduplessis
janicduplessis marked this pull request as ready for review November 29, 2026 00:42
@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 29, 2026
@janicduplessis
janicduplessis enabled auto-merge (squash) November 29, 2026 00:42
@janicduplessis
janicduplessis merged commit 23a4906 into main Nov 29, 2026
75 of 76 checks passed
@janicduplessis
janicduplessis deleted the fix/6633-windows-install-carry branch November 29, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli packages/stim-cli, including its README and guide area: docs docs/ and root documents ci-full run the macOS, Windows, Desktop and license jobs on this pull request review: ai-approved A fresh AI review found nothing left to fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: a build in a warmed npm worktree is never cached (package-lock.json changed after the last install)

1 participant