diff --git a/desktop-package/scripts/notarize.js b/desktop-package/scripts/notarize.js index a39a9b8fd6..929fc94502 100644 --- a/desktop-package/scripts/notarize.js +++ b/desktop-package/scripts/notarize.js @@ -1,6 +1,28 @@ require('dotenv').config(); const { notarize } = require('@electron/notarize'); +async function retryNotarize(options, retries = 5, delay = 5000) { + for (let i = 0; i < retries; i++) { + try { + console.log(`Attempt ${i + 1} to notarize...`); + await notarize(options); + console.log('Notarization successful'); + return; + } catch (error) { + console.error(`Notarization attempt ${i + 1} failed:`, error); + if (i < retries - 1) { + console.log(`Retrying in ${delay / 1000} seconds...`); + await new Promise(resolve => setTimeout(resolve, delay)); + delay *= 2; // Increase delay for the next retry + } else { + console.log('All notarization attempts failed...'); + // Add any necessary teardown logic here + throw error; + } + } + } +} + exports.default = async function notarizing(context) { const { electronPlatformName, appOutDir } = context; if (electronPlatformName !== 'darwin') { @@ -9,8 +31,8 @@ exports.default = async function notarizing(context) { const appName = context.packager.appInfo.productFilename; - console.log('Starting custom notarization process...') - return await notarize({ + console.log('Starting custom notarization process...'); + await retryNotarize({ appPath: `${appOutDir}/${appName}.app`, appleId: process.env.APPLE_ID, appleIdPassword: process.env.APPLE_ID_APP_PASS,