(appPath, options = {})
| 197 | } |
| 198 | |
| 199 | async function launchFixtureWithRecovery(appPath, options = {}) { |
| 200 | const recoveryCount = options.recoveryCount ?? 0; |
| 201 | const maxRecoveries = options.maxRecoveries ?? fixtureLaunchMaxRecoveries; |
| 202 | |
| 203 | simdeckJson(["install", simulatorUDID, appPath], { |
| 204 | timeoutMs: 60_000, |
| 205 | }); |
| 206 | |
| 207 | let launchError = null; |
| 208 | try { |
| 209 | simdeckJson(["launch", simulatorUDID, fixtureBundleId], { |
| 210 | timeoutMs: 180_000, |
| 211 | }); |
| 212 | } catch (error) { |
| 213 | launchError = error; |
| 214 | } |
| 215 | |
| 216 | let urlError = null; |
| 217 | if (launchError === null) { |
| 218 | try { |
| 219 | await retrySimdeckJson( |
| 220 | ["open-url", simulatorUDID, fixtureAnimateUrl], |
| 221 | "WebRTC start fixture animation", |
| 222 | { |
| 223 | attempts: 3, |
| 224 | delayMs: 5_000, |
| 225 | timeoutMs: 180_000, |
| 226 | }, |
| 227 | ); |
| 228 | return; |
| 229 | } catch (error) { |
| 230 | urlError = error; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if ( |
| 235 | !shouldRecycleSimulatorForFixtureLaunch({ |
| 236 | launchError, |
| 237 | urlError, |
| 238 | recoveryCount, |
| 239 | maxRecoveries, |
| 240 | }) |
| 241 | ) { |
| 242 | throw urlError ?? launchError; |
| 243 | } |
| 244 | |
| 245 | console.warn( |
| 246 | `WebRTC fixture activation hit ${activationRecoveryReason({ |
| 247 | launchError, |
| 248 | urlError, |
| 249 | })}; recycling simulator and retrying once.`, |
| 250 | ); |
| 251 | await recycleSimulatorForFixtureLaunch(); |
| 252 | return launchFixtureWithRecovery(appPath, { |
| 253 | recoveryCount: recoveryCount + 1, |
| 254 | maxRecoveries, |
| 255 | }); |
| 256 | } |
no test coverage detected