From c640b70836d3e943e777c4eea35a464f3fbd884f Mon Sep 17 00:00:00 2001
From: Badcuban <108198679+badcuban@users.noreply.github.com>
Date: Wed, 18 Nov 2026 12:07:38 -0500
Subject: [PATCH] fix(release): the Mac build retries when Apple's timestamp
server drops a signature
The Nov 17 nightly failed in the macOS job when codesign printed
"A timestamp was expected but was not found" for one Electron locale
file. Apple's timestamp server drops requests now and then, and the same
signature works on the next try. The packaging retry only knew network
errors, so it failed on the first attempt.
retryTransientElectronPackaging now also retries on codesign's two
timestamp-server messages, with the same two-retry limit.
---
scripts/build-desktop-artifact.test.ts | 22 +++++++++++++++++++
scripts/build-desktop-artifact.ts | 30 +++++++++++++++++++++++---
2 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts
index 1c4cbd97b..ed59d1d73 100644
--- a/scripts/build-desktop-artifact.test.ts
+++ b/scripts/build-desktop-artifact.test.ts
@@ -121,6 +121,28 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
}),
);
+ it.effect("retries Electron packaging when Apple's timestamp server drops a signature", () =>
+ Effect.gen(function* () {
+ let attempts = 0;
+ const result = yield* retryTransientElectronPackaging(
+ Effect.suspend(() => {
+ attempts += 1;
+ return attempts < 2
+ ? Effect.fail(
+ new TestFailure({
+ message:
+ "Command failed: codesign --sign ... locale.pak\nlocale.pak: A timestamp was expected but was not found.",
+ }),
+ )
+ : Effect.succeed("built");
+ }),
+ );
+
+ assert.equal(result, "built");
+ assert.equal(attempts, 2);
+ }),
+ );
+
it.effect("does not retry non-network packaging failures", () =>
Effect.gen(function* () {
let attempts = 0;
diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts
index 1c12eb445..df8f8d530 100644
--- a/scripts/build-desktop-artifact.ts
+++ b/scripts/build-desktop-artifact.ts
@@ -564,20 +564,44 @@ const runCommand = Effect.fn("runCommand")(function* (command: ChildProcess.Comm
}
});
+/**
+ * What codesign prints when Apple's timestamp server (timestamp.apple.com)
+ * doesn't answer `--timestamp`. The server drops requests now and then; the
+ * same signature succeeds on the next try.
+ */
+const APPLE_TIMESTAMP_FAILURE_PATTERNS = [
+ "a timestamp was expected but was not found",
+ "the timestamp service is not available",
+] as const;
+
+function isAppleTimestampFailure(error: unknown): boolean {
+ const message = (error instanceof Error ? error.message : String(error)).toLowerCase();
+ return APPLE_TIMESTAMP_FAILURE_PATTERNS.some((pattern) => message.includes(pattern));
+}
+
+function isTransientPackagingFailure(error: unknown): boolean {
+ return isTransientNetworkFailure(error) || isAppleTimestampFailure(error);
+}
+
+/**
+ * Runs electron-builder again, up to twice, when it fails on a network blip or
+ * on Apple's timestamp server. Each run re-extracts Electron and signs from
+ * scratch, so a retry never sees a half-signed app.
+ */
export function retryTransientElectronPackaging(
packaging: Effect.Effect,
): Effect.Effect {
return packaging.pipe(
Effect.tapError((error) =>
- isTransientNetworkFailure(error)
+ isTransientPackagingFailure(error)
? Effect.logWarning(
- "[desktop-artifact] Electron packaging hit a transient network failure; bounded retry policy active.",
+ "[desktop-artifact] Electron packaging hit a transient network or code-signing timestamp failure; bounded retry policy active.",
)
: Effect.void,
),
Effect.retry({
times: 2,
- while: isTransientNetworkFailure,
+ while: isTransientPackagingFailure,
}),
);
}