fix(KAN-58): retry transient public downloads for macOS 0.1.1
CI/CD / preconditions (pull_request) Successful in 2s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m4s
macOS checks / Native Rust tests and unsigned build (pull_request) Successful in 1m28s
CI/CD / Publish immutable image (pull_request) Canceled after 0s
CI/CD / test_and_check_app (pull_request) Canceled after 2m15s

This commit is contained in:
2026-09-27 16:37:16 +02:00
parent d8ca4975e5
commit 4dd73ec583
6 changed files with 125 additions and 15 deletions
+39 -10
View File
@@ -10,6 +10,7 @@ import {
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import process from 'node:process';
import { setTimeout } from 'node:timers/promises';
import { pathToFileURL } from 'node:url';
import { execute, releaseMetadata } from './macos-ci.mjs';
@@ -62,6 +63,7 @@ export async function publishMacos({
metadata,
run = execute,
fetchPublic = fetch,
wait = setTimeout,
} = {}) {
const storage = storageConfiguration(env);
if (!env.AWS_ACCESS_KEY_ID || !env.AWS_SECRET_ACCESS_KEY) {
@@ -123,16 +125,43 @@ export async function publishMacos({
const keyPrefix = `${storage.prefix}/${metadata.target}/${metadata.version}`;
const publicPrefix = `${storage.publicBase}/${keyPrefix}`;
async function verifyPublic(name, contents) {
const response = await fetchPublic(`${publicPrefix}/${name}`, {
redirect: 'error',
signal: AbortSignal.timeout(60000),
});
if (
!response.ok ||
sha256(Buffer.from(await response.arrayBuffer())) !==
sha256(contents)
) {
throw new Error(`Public download verification failed for ${name}.`);
for (let attempt = 1; attempt <= 5; attempt++) {
let response;
try {
response = await fetchPublic(`${publicPrefix}/${name}`, {
redirect: 'error',
signal: AbortSignal.timeout(60000),
});
} catch (error) {
if (attempt === 5) {
throw new Error(
`Public download request failed for ${name}: ${error.message}`,
);
}
await wait(2000);
continue;
}
if (response.ok) {
if (
sha256(Buffer.from(await response.arrayBuffer())) !==
sha256(contents)
) {
throw new Error(
`Public download verification failed for ${name}: SHA-256 mismatch.`,
);
}
return;
}
await response.body?.cancel();
const retryable = [403, 404, 408, 429, 500, 502, 503, 504].includes(
response.status,
);
if (!retryable || attempt === 5) {
throw new Error(
`Public download verification failed for ${name}: HTTP ${response.status}.`,
);
}
await wait(2000);
}
}
function putImmutable(name, contents, contentType) {