From cf4ab2186c6266d0942f3f91349ccbf49e76f14b Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 17 Sep 2024 14:49:59 -0700 Subject: [PATCH] build: improve logging on http errors during release process (again) (#43757) --- script/release/get-asset.js | 11 +++-------- script/release/release.js | 8 ++++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/script/release/get-asset.js b/script/release/get-asset.js index 3658530337df..086e0bf540a9 100644 --- a/script/release/get-asset.js +++ b/script/release/get-asset.js @@ -26,9 +26,9 @@ async function getAssetContents (repo, assetId) { throwHttpErrors: false }); - if (response.status !== 302 && response.status !== 301) { + if (response.statusCode !== 302 && response.statusCode !== 301) { console.error('Failed to HEAD github asset contents for redirect: ' + url); - throw new Error('Unexpected status HEAD\'ing github asset: ' + response.status); + throw new Error('Unexpected status HEAD\'ing github asset for redirect: ' + response.statusCode); } if (!response.headers.location) { @@ -40,14 +40,9 @@ async function getAssetContents (repo, assetId) { throwHttpErrors: false }); - if (fileResponse.status !== 200) { - fileResponse.error(`Failed to download github asset contents: ${url} (via: ${response.headers.location})`); - throw new Error('Unexpected status fetching github asset: ' + fileResponse.status); - } - if (fileResponse.statusCode !== 200) { console.error(fileResponse.headers, `${fileResponse.body}`.slice(0, 300)); - throw new Error(`cannot download asset[${assetId}] from ${response.headers.location}, got status: ${fileResponse.status}`); + throw new Error(`cannot download asset[${assetId}] from ${response.headers.location}, got status: ${fileResponse.statusCode}`); } return fileResponse.body; diff --git a/script/release/release.js b/script/release/release.js index 8977ad49e2b1..f4ca11af7b73 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -401,9 +401,9 @@ async function verifyDraftGitHubReleaseAssets (release) { throwHttpErrors: false }); - if (response.status !== 200) { + if (response.statusCode !== 200) { console.error('Failed to HEAD github asset: ' + url); - throw new Error('Unexpected status HEAD\'ing github asset: ' + response.status); + throw new Error('Unexpected status HEAD\'ing github asset: ' + response.statusCode); } return { url: response.headers.location, file: asset.name }; @@ -420,10 +420,10 @@ async function getShaSumMappingFromUrl (shaSumFileUrl, fileNamePrefix) { throwHttpErrors: false }); - if (response.status !== 200) { + if (response.statusCode !== 200) { console.error('Failed to fetch SHASUM mapping: ' + shaSumFileUrl); console.error('Bad SHASUM mapping response: ' + response.body.trim()); - throw new Error('Unexpected status fetching SHASUM mapping: ' + response.status); + throw new Error('Unexpected status fetching SHASUM mapping: ' + response.statusCode); } const raw = response.body;