fix: address pr-bug-scan validated finding from #7174

Made resolveServeSimExecutable() lazy in IosEmulatorBackend via a cached getter; constructor no longer triggers the startup cpSync+xattr on darwin first-launch.
This commit is contained in:
orca-bug-scan-bot
2026-07-03 21:18:59 -07:00
parent a4661f15d3
commit d1dd4d3c1e
@@ -46,14 +46,25 @@ export class IosEmulatorBackend implements EmulatorBackend {
logcat: false
}
private readonly serveSimExecutable: ServeSimExecutable
private serveSimExecutableCache: ServeSimExecutable | undefined
private readonly waitForEndpointReady: (endpoint: string) => Promise<boolean>
constructor(options: EmulatorBridgeOptions = {}) {
this.serveSimExecutable = resolveServeSimExecutable()
this.waitForEndpointReady = options.waitForEndpointReady ?? waitForServeSimEndpointReady
}
// Why: resolving the executable can materialize the serve-sim runtime (a
// recursive copy + xattr subprocess on darwin first-launch-per-version), so
// defer it to first actual use. Constructing this backend at app startup
// (inside app.whenReady, before the main window opens) must not block the
// main thread on that work.
private get serveSimExecutable(): ServeSimExecutable {
if (!this.serveSimExecutableCache) {
this.serveSimExecutableCache = resolveServeSimExecutable()
}
return this.serveSimExecutableCache
}
isSupportedOnHost(): boolean {
return platform() === 'darwin'
}