mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(sidecar): serialize WDA reconnect with ReentrantLock to prevent concurrent xcodebuild races
This commit is contained in:
1 parent
8c6c8c85df
commit
0681272078
1 file changed
+6
@@ -488,6 +488,7 @@ private fun pngHeight(bytes: ByteArray): Int {
|
|||||||
|
|
||||||
class IosDriverBackend(private val udid: String) : DriverBackend {
|
class IosDriverBackend(private val udid: String) : DriverBackend {
|
||||||
private lateinit var driver: maestro.drivers.IOSDriver
|
private lateinit var driver: maestro.drivers.IOSDriver
|
||||||
|
private val reconnectLock = java.util.concurrent.locks.ReentrantLock()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val httpClient = xcuitest.api.OkHttpClientInstance.get()
|
val httpClient = xcuitest.api.OkHttpClientInstance.get()
|
||||||
@@ -534,10 +535,15 @@ class IosDriverBackend(private val udid: String) : DriverBackend {
|
|||||||
val isIoFailure = generateSequence(e as Throwable) { it.cause }
|
val isIoFailure = generateSequence(e as Throwable) { it.cause }
|
||||||
.any { it is java.io.IOException }
|
.any { it is java.io.IOException }
|
||||||
if (!isIoFailure) throw e
|
if (!isIoFailure) throw e
|
||||||
|
reconnectLock.lock()
|
||||||
|
try {
|
||||||
try { driver.open(); warmup() }
|
try { driver.open(); warmup() }
|
||||||
catch (reconnectErr: Exception) {
|
catch (reconnectErr: Exception) {
|
||||||
throw IllegalStateException("WDA reconnect failed: $reconnectErr", e)
|
throw IllegalStateException("WDA reconnect failed: $reconnectErr", e)
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
reconnectLock.unlock()
|
||||||
|
}
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user