Skip to content

Commit ee4bd4a

Browse files
committed
fix(scripts): give the artifact mtime repair a millisecond of headroom
checks-node-core-tooling-2 failed on main (run 31943910358) with 'expected 1786879225197 to be >= 1786879225197.2246': the repaired output mtime landed a fraction of a millisecond below the input it had to clear. isArtifactSetFresh repairs output mtimes to exactly ceil(newestInput), so it leaves zero headroom for sub-millisecond write rounding or lagging metadata on CI filesystems. When the repair lands at or below its input the mtime fast path never engages, and every later invocation in that checkout falls back to re-hashing every input byte -- the expensive path this repair exists to avoid, gating the d.ts emit that is the slowest build-all phase (25.9s of a 61s build). Neither macOS APFS nor an idle Linux ext4 Testbox reproduces the shortfall in 300 runs, so the repair now clears the newest input by a whole millisecond instead of matching it. The assertion pins that headroom, making the test deterministic where it was previously load-dependent (fails 615 vs 616 without the fix).
1 parent 96cacfd commit ee4bd4a

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎scripts/prepare-extension-package-boundary-artifacts.mts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,12 @@ export function isArtifactSetFresh(params: ArtifactFreshParams) {
558558
return false;
559559
}
560560
// Repair the mtime fast path so later invocations in this checkout skip
561-
// without re-reading every input byte.
562-
const now = new Date(Math.max(Date.now(), Math.ceil(newestInputMtimeMs)));
561+
// without re-reading every input byte. The extra millisecond is required,
562+
// not cosmetic: landing exactly on the newest input leaves no headroom for
563+
// sub-millisecond write rounding or lagging metadata on CI filesystems, and
564+
// an output that lands at or below its input silently keeps every later
565+
// invocation on the expensive full-hash path this repair exists to avoid.
566+
const now = new Date(Math.max(Date.now(), Math.ceil(newestInputMtimeMs)) + 1);
563567
for (const relativePath of params.outputPaths) {
564568
const outputPath = resolve(rootDir, relativePath);
565569
if (fs.existsSync(outputPath)) {

‎test/scripts/prepare-extension-package-boundary-artifacts.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,12 @@ describe("prepare-extension-package-boundary-artifacts", () => {
596596
vi.setSystemTime(repairTimeMs);
597597
try {
598598
expect(isArtifactSetFresh(freshParams)).toBe(true);
599-
// Round past fractional filesystem precision so the next check takes the fast path.
599+
// The repaired output must clear the newest input by a whole millisecond.
600+
// Matching it exactly leaves no headroom for sub-millisecond write
601+
// rounding or lagging metadata, and a CI runner that lands even a
602+
// fraction short puts every later invocation back on the full-hash path.
600603
expect(fs.statSync(outputPath).mtimeMs).toBeGreaterThanOrEqual(
601-
fs.statSync(inputPath).mtimeMs,
604+
Math.ceil(fs.statSync(inputPath).mtimeMs) + 1,
602605
);
603606
} finally {
604607
vi.useRealTimers();

0 commit comments

Comments
 (0)