Unverified Commit d35864d5 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[cd] Tolerate 409 when uploading preview tarballs (#99091)

A rerun or new run on the same commit currently reuploads and overwrites
the tarballs. Mostly to accomodate full runs on a commit to get all the
binaries (regular runs only build for Linux).

Instead, we'll soon return a 409 from the server so that a tarball can
be served as immutable.

This PR makes the client resilient against 409s. 

If we ever build different variants for the same commit, we should
update the route instead to reflect different build variants. This is
would be the better choice anyway so that you know what build variant is
behind a commit.
Co-authored-by: 's avatarClaude Code (kimi-k3[1m]) <noreply@anthropic.com>
parent 5a46fc6c
...@@ -209,7 +209,19 @@ async function uploadPackageTarball({ ...@@ -209,7 +209,19 @@ async function uploadPackageTarball({
{ cause: error } { cause: error }
) )
} }
if (!response.ok) {
if (response.status === 409) {
/** @type {{ downloadUrl: string }} */
const body = await response.json()
// The server treats commits as immutable and rejects re-uploads once a
// tarball exists. Re-runs legitimately re-request paths that already
// went up (e.g. a re-run that rebuilds native packages re-requests the
// unchanged JS-only ones), so a conflict means this package is done.
console.info(`${packageName} is already published, skipping`)
return body.downloadUrl
}
if (!response.ok && response.status !== 409) {
throw new Error( throw new Error(
`Failed to authorize the upload of ${packageName}: ${response.status}.${await readResponseDetails(response)}` `Failed to authorize the upload of ${packageName}: ${response.status}.${await readResponseDetails(response)}`
) )
...@@ -267,7 +279,7 @@ async function main() { ...@@ -267,7 +279,7 @@ async function main() {
getOidcToken, getOidcToken,
}) })
) )
console.info(`Uploaded ${packageName} -> ${downloadUrl}`) console.info(`${packageName} available at ${downloadUrl}`)
} catch (error) { } catch (error) {
failedUploads.push( failedUploads.push(
new Error(`Failed to upload ${packageName}`, { cause: error }) new Error(`Failed to upload ${packageName}`, { cause: error })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment