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 {
return try {
block()
} catch (e: java.io.IOException) {
try {
driver.open()
warmup()
} catch (reconnectErr: Exception) {
} catch (e: Exception) {
val isIoFailure = generateSequence(e as Throwable) { it.cause }
.any { it is java.io.IOException }
if (!isIoFailure) throw e
try { driver.open(); warmup() }
catch (reconnectErr: Exception) {
throw IllegalStateException("WDA reconnect failed: $reconnectErr", e)
}
block()