mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07: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 {
|
||||
private lateinit var driver: maestro.drivers.IOSDriver
|
||||
private val reconnectLock = java.util.concurrent.locks.ReentrantLock()
|
||||
|
||||
init {
|
||||
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 }
|
||||
.any { it is java.io.IOException }
|
||||
if (!isIoFailure) throw e
|
||||
reconnectLock.lock()
|
||||
try {
|
||||
try { driver.open(); warmup() }
|
||||
catch (reconnectErr: Exception) {
|
||||
throw IllegalStateException("WDA reconnect failed: $reconnectErr", e)
|
||||
}
|
||||
} finally {
|
||||
reconnectLock.unlock()
|
||||
}
|
||||
block()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user