From 95b9c08651eb20b69f552782800f581942cb4576 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Sat, 3 May 2025 08:00:36 +0000 Subject: [PATCH] build: improve stability of windows jobs further MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the recent commit to rework the convert symlink script, we addressed the high flakiness of module resolution errors due to broken/missing symlinks. Though, this commit introduces a new source of flakiness that we tried to avoid in the past— running too many WSL exe's at the same time. We fix this by reducing the batch size and adding another retry for safety. In addition, the patch branch uses an older NodeJS version where `fs.cp` seems to have issues when the source files are readonly— so we fix that by just invoking the shell's `cp` command. That one works --- scripts/windows-testing/convert-symlinks.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/windows-testing/convert-symlinks.mjs b/scripts/windows-testing/convert-symlinks.mjs index 168e4adba19e..a170e350dae2 100644 --- a/scripts/windows-testing/convert-symlinks.mjs +++ b/scripts/windows-testing/convert-symlinks.mjs @@ -75,7 +75,8 @@ async function transformDir(p) { } else { dereferenceFns.push(async () => { await fs.unlink(subPath); - await fs.cp(realTarget, subPath, { recursive: true }); + // Note: NodeJS `fs.cp` can have issues when sources are readonly. + await exec(`cp -R ${realTarget} ${subPath}`); }); } } else if (file.isDirectory()) { @@ -86,7 +87,7 @@ async function transformDir(p) { await Promise.all(directoriesToVisit.map((d) => transformDir(d))); } -function exec(cmd, maxRetries = 2) { +function exec(cmd, maxRetries = 3) { return new Promise((resolve, reject) => { childProcess.exec(cmd, { cwd: rootDir }, (error) => { if (error !== null) { @@ -119,7 +120,7 @@ try { // Re-link symlinks to work inside Windows. // This is done in batches to avoid flakiness due to WSL // See: https://github.com/microsoft/WSL/issues/8677. - const batchSize = 100; + const batchSize = 75; for (let i = 0; i < relinkFns.length; i += batchSize) { await Promise.all(relinkFns.slice(i, i + batchSize).map((fn) => fn())); }