diff --git a/tools/desktop-release.ts b/tools/desktop-release.ts index 0195f7a..73ac7ab 100644 --- a/tools/desktop-release.ts +++ b/tools/desktop-release.ts @@ -518,10 +518,13 @@ async function mac(argv: string[]): Promise { if (dmgNotary) { let n = await dmgNotary; - // an upload cut off on the way to Apple (abortedUpload, a reset connection) submitted nothing: send it once more - if (n.code !== 0 && /abortedUpload|connection (was )?reset|timed out|network connection was lost/i.test(n.err + n.out)) { - say('notarytool: the DMG upload was cut off before Apple had it; submitting once more'); - n = await runAsync(['xcrun', 'notarytool', 'submit', dmg, '--key', notary!.APPLE_API_KEY_PATH!, '--key-id', notary!.APPLE_API_KEY!, '--issuer', notary!.APPLE_API_ISSUER!, '--wait', '--output-format', 'json'], { timeoutMs: 3_600_000 }); + // an upload cut off on the way to Apple (abortedUpload, a reset connection) submitted nothing: send it again, up + // to 3 tries, the later ones without S3 transfer acceleration (the path that broke twice for 0.8.12); the exit + // code is not trusted, only notarytool's own status + const accepted = (o: string) => { try { return (JSON.parse(o) as { status?: string }).status === 'Accepted'; } catch { return false; } }; + for (let tries = 1; tries < 3 && !accepted(n.out) && /abortedUpload|connection (was )?reset|timed out|network connection was lost|NSURLErrorDomain/i.test(n.err + n.out); tries++) { + say(`notarytool: the DMG upload was cut off before Apple had it (try ${tries}); submitting again without S3 acceleration`); + n = await runAsync(['xcrun', 'notarytool', 'submit', dmg, '--key', notary!.APPLE_API_KEY_PATH!, '--key-id', notary!.APPLE_API_KEY!, '--issuer', notary!.APPLE_API_ISSUER!, '--no-s3-acceleration', '--wait', '--output-format', 'json'], { timeoutMs: 3_600_000 }); } const status = (() => { try { return (JSON.parse(n.out) as { status?: string }).status; } catch { return undefined; } })(); if (status !== 'Accepted') fail(`notarization of the DMG: ${status ?? (n.err.trim() || n.out.trim() || `notarytool exited ${n.code} without an answer (killed or timed out): run again; xcrun notarytool history shows the submission`)}`);