Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions app-runner/Private/DeviceProviders/XboxProvider.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,26 @@ class XboxProvider : DeviceProvider {
[hashtable] Connect() {
Write-Debug "$($this.Platform): Connecting to device"
$this.InvokePowerOn() # Wakes up the device - needs to run before connect.
$this.InvokeCommand('connect', @())
return $this.CreateSessionInfo()

# Retry in case the device SYSTEM is temporarily unreachable (e.g. recovering
# from a previous test crash). xbconnect exits non-zero immediately in that case,
# which bypasses the timeout-based retry in InvokeCommandWithTimeoutAndRetry.
$maxAttempts = 4
$retryDelaySeconds = 30
for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
try {
$this.InvokeCommand('connect', @())
return $this.CreateSessionInfo()
} catch {
if ($attempt -lt $maxAttempts) {
Write-Warning "$($this.Platform): Connect attempt $attempt of $maxAttempts failed, retrying in $retryDelaySeconds seconds... ($_)"
Start-Sleep -Seconds $retryDelaySeconds
} else {
throw
}
}
}
throw "Connect failed after $maxAttempts attempts"
}

# Override Connect to support target parameter
Expand Down
Loading