From 57f9a78a38476fe26884cb6c9b31ae01c71f8879 Mon Sep 17 00:00:00 2001 From: Rob Snow Date: Thu, 11 Jun 2026 11:42:08 +1000 Subject: [PATCH 1/2] fix: speed up and fix v-publish-stats --- scripts/compareSize.js | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/compareSize.js b/scripts/compareSize.js index 905aa10db5f..8dce8e5a29f 100644 --- a/scripts/compareSize.js +++ b/scripts/compareSize.js @@ -26,23 +26,22 @@ async function compareBuildAppSize() { let lastPublishStatUrl = `https://reactspectrum.blob.core.windows.net/reactspectrum/${commit}/verdaccio/rsp-cra-18/publish-stats/${currentPublishStatsFile}`; let lastAppStatPath = path.join(__dirname, '..', lastAppStatsFile); let lastPublishStatPath = path.join(__dirname, '..', lastPublishStatsFile); - await download(lastAppStatUrl, lastAppStatPath); - await download(lastPublishStatUrl, lastPublishStatPath); + await Promise.all([ + download(lastAppStatUrl, lastAppStatPath), + download(lastPublishStatUrl, lastPublishStatPath) + ]); - if (!fs.existsSync(lastAppStatPath)) { - // TODO: placeholder until we get some real stats. Hardcoded URL pointing to a commit with actual data - await download( + await Promise.all([ + !fs.existsSync(lastAppStatPath) && download( + // TODO: placeholder until we get some real stats. Hardcoded URL pointing to a commit with actual data `https://reactspectrum.blob.core.windows.net/reactspectrum/2504f8ad927d0d0ad55e7e6db8a22fec16a67b6f/verdaccio/publish-stats/${currentAppStatsFile}`, lastAppStatPath - ); - } - - if (!fs.existsSync(lastPublishStatPath)) { - await download( + ), + !fs.existsSync(lastPublishStatPath) && download( `https://reactspectrum.blob.core.windows.net/reactspectrum/2504f8ad927d0d0ad55e7e6db8a22fec16a67b6f/verdaccio/publish-stats/${currentPublishStatsFile}`, lastPublishStatPath - ); - } + ) + ]); // Extract the built example app size from the current commit and the last publish commit data let lastAppStats = fs.readFileSync(lastAppStatsFile, 'utf8'); @@ -109,13 +108,27 @@ function download(url, dest) { }); } }); + response.on('error', err => { + file.close(); + fs.unlink(dest, () => { + console.error(err); + resolve(); + }); + }); response.pipe(file); } else { console.error(`Server responded with ${response.statusCode}: ${response.statusMessage}`); + response.resume(); // drain the response so the socket is released resolve(); } }); + request.setTimeout(30000, () => { + request.destroy(); + console.error(`Request timed out: ${url}`); + resolve(); + }); + request.on('error', err => { console.error(err); resolve(); From 4ae77f4dc785888838942ce56a8abc8c8d1e9996 Mon Sep 17 00:00:00 2001 From: Rob Snow Date: Thu, 11 Jun 2026 11:45:51 +1000 Subject: [PATCH 2/2] fix formatting --- scripts/compareSize.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/compareSize.js b/scripts/compareSize.js index 8dce8e5a29f..0438e27f762 100644 --- a/scripts/compareSize.js +++ b/scripts/compareSize.js @@ -32,15 +32,17 @@ async function compareBuildAppSize() { ]); await Promise.all([ - !fs.existsSync(lastAppStatPath) && download( - // TODO: placeholder until we get some real stats. Hardcoded URL pointing to a commit with actual data - `https://reactspectrum.blob.core.windows.net/reactspectrum/2504f8ad927d0d0ad55e7e6db8a22fec16a67b6f/verdaccio/publish-stats/${currentAppStatsFile}`, - lastAppStatPath - ), - !fs.existsSync(lastPublishStatPath) && download( - `https://reactspectrum.blob.core.windows.net/reactspectrum/2504f8ad927d0d0ad55e7e6db8a22fec16a67b6f/verdaccio/publish-stats/${currentPublishStatsFile}`, - lastPublishStatPath - ) + !fs.existsSync(lastAppStatPath) && + download( + // TODO: placeholder until we get some real stats. Hardcoded URL pointing to a commit with actual data + `https://reactspectrum.blob.core.windows.net/reactspectrum/2504f8ad927d0d0ad55e7e6db8a22fec16a67b6f/verdaccio/publish-stats/${currentAppStatsFile}`, + lastAppStatPath + ), + !fs.existsSync(lastPublishStatPath) && + download( + `https://reactspectrum.blob.core.windows.net/reactspectrum/2504f8ad927d0d0ad55e7e6db8a22fec16a67b6f/verdaccio/publish-stats/${currentPublishStatsFile}`, + lastPublishStatPath + ) ]); // Extract the built example app size from the current commit and the last publish commit data