fix(sidecar): walk cause chain in withReconnect to catch Maestro-wrapped IOException

This commit is contained in:
pj committed 2026-04-25 15:33:41 +07:00
1 parent 0f1f3eb457
commit 665831ffd7
1 file changed
+6 -5
@@ -530,11 +530,12 @@ class IosDriverBackend(private val udid: String) : DriverBackend {
private fun <T> withReconnect(block: () -> T): T { private fun <T> withReconnect(block: () -> T): T {
return try { return try {
block() block()
} catch (e: java.io.IOException) { } catch (e: Exception) {
try { val isIoFailure = generateSequence(e as Throwable) { it.cause }
driver.open() .any { it is java.io.IOException }
warmup() if (!isIoFailure) throw e
} catch (reconnectErr: Exception) { try { driver.open(); warmup() }
catch (reconnectErr: Exception) {
throw IllegalStateException("WDA reconnect failed: $reconnectErr", e) throw IllegalStateException("WDA reconnect failed: $reconnectErr", e)
} }
block() block()