Skip to content

feat(bundler): allow customizing DMG detach attempts via env vars#15169

Open
tranhoangtu-it wants to merge 1 commit intotauri-apps:devfrom
tranhoangtu-it:feat/dmg-detach-configurable
Open

feat(bundler): allow customizing DMG detach attempts via env vars#15169
tranhoangtu-it wants to merge 1 commit intotauri-apps:devfrom
tranhoangtu-it:feat/dmg-detach-configurable

Conversation

@tranhoangtu-it
Copy link
Copy Markdown

close #14686

On CI with large DMG files, hdiutil detach frequently times out with EBUSY (exit code 16). The retry loop in hdiutil_detach_retry had 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

TAURI_DMG_DETACH_ATTEMPTS=10 TAURI_DMG_DETACH_DELAY=2 cargo tauri build

No behavior change when env vars are unset.

@tranhoangtu-it tranhoangtu-it requested a review from a team as a code owner March 28, 2026 17:01
Copilot AI review requested due to automatic review settings March 28, 2026 17:01
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Mar 28, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ATTEMPTS to control the max detach attempts (default 3).
  • Reads TAURI_DMG_DETACH_DELAY to control the exponential-backoff base delay (default 1 second).
  • Uses the configured delay in the sleep backoff 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}"
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@@ -35,7 +35,8 @@ HDIUTIL_VERBOSITY=""
SANDBOX_SAFE=0
BLESS=0
SKIP_JENKINS=0
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
SKIP_JENKINS=0
SKIP_JENKINS=0
# Total number of detach attempts (including the first), controlled via TAURI_DMG_DETACH_ATTEMPTS

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

Consider allowing the user to customize the detach attempts / time

2 participants