feat(bundler): allow customizing DMG detach attempts via env vars#15169
feat(bundler): allow customizing DMG detach attempts via env vars#15169tranhoangtu-it wants to merge 1 commit intotauri-apps:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds configurability to the macOS DMG bundling script’s hdiutil detach retry behavior to better handle CI timeouts/EBUSY scenarios, while preserving current defaults when the new env vars are unset.
Changes:
- Reads
TAURI_DMG_DETACH_ATTEMPTSto control the max detach attempts (default3). - Reads
TAURI_DMG_DETACH_DELAYto control the exponential-backoff base delay (default1second). - Uses the configured delay in the
sleepbackoff calculation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SKIP_JENKINS=0 | ||
| MAXIMUM_UNMOUNTING_ATTEMPTS=3 | ||
| MAXIMUM_UNMOUNTING_ATTEMPTS="${TAURI_DMG_DETACH_ATTEMPTS:-3}" | ||
| DMG_DETACH_DELAY="${TAURI_DMG_DETACH_DELAY:-1}" |
There was a problem hiding this comment.
MAXIMUM_UNMOUNTING_ATTEMPTS and DMG_DETACH_DELAY come directly from env vars but are later used in (( ... )) / $(( ... )). With set -e, non-integer/empty/negative values (e.g. TAURI_DMG_DETACH_ATTEMPTS=abc or TAURI_DMG_DETACH_DELAY=0.5) can trigger an arithmetic error and abort the script (or result in a 0s sleep and tight retry loop). Consider validating these as positive integers up front and either falling back to defaults or exiting with a clear error message.
| DMG_DETACH_DELAY="${TAURI_DMG_DETACH_DELAY:-1}" | |
| DMG_DETACH_DELAY="${TAURI_DMG_DETACH_DELAY:-1}" | |
| # Validate numeric configuration derived from environment | |
| if ! [[ "$MAXIMUM_UNMOUNTING_ATTEMPTS" =~ ^[1-9][0-9]*$ ]]; then | |
| echo "Warning: TAURI_DMG_DETACH_ATTEMPTS must be a positive integer; using default 3." >&2 | |
| MAXIMUM_UNMOUNTING_ATTEMPTS=3 | |
| fi | |
| if ! [[ "$DMG_DETACH_DELAY" =~ ^[1-9][0-9]*$ ]]; then | |
| echo "Warning: TAURI_DMG_DETACH_DELAY must be a positive integer; using default 1." >&2 | |
| DMG_DETACH_DELAY=1 | |
| fi |
| @@ -35,7 +35,8 @@ HDIUTIL_VERBOSITY="" | |||
| SANDBOX_SAFE=0 | |||
| BLESS=0 | |||
| SKIP_JENKINS=0 | |||
There was a problem hiding this comment.
The loop increments unmounting_attempts before attempting hdiutil detach, and exits when unmounting_attempts == MAXIMUM_UNMOUNTING_ATTEMPTS, so this variable currently represents the total number of detach attempts, not the number of retries after the first attempt. Since TAURI_DMG_DETACH_ATTEMPTS is a user-facing knob, it would help to either (a) adjust the logic so the env var truly means “retries”, or (b) add an inline comment clarifying it is “total attempts (including the first)”, to prevent off-by-one surprises.
| SKIP_JENKINS=0 | |
| SKIP_JENKINS=0 | |
| # Total number of detach attempts (including the first), controlled via TAURI_DMG_DETACH_ATTEMPTS |
close #14686
On CI with large DMG files,
hdiutil detachfrequently times out withEBUSY(exit code 16). The retry loop inhdiutil_detach_retryhad both the attempt count and the sleep base delay hardcoded.Changes
Two env vars with backward-compatible defaults:
TAURI_DMG_DETACH_ATTEMPTS— max retries (default:3)TAURI_DMG_DETACH_DELAY— base delay in seconds for exponential backoff (default:1)Usage
No behavior change when env vars are unset.