mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 06:19:21 +00:00
startVstSidecar()'s singleton guard only checked the module-level `running` variable, which is assigned inside the async ready-handshake callback. A second concurrent call landing before the first child became ready saw `running === null` and spawned its own child, orphaning whichever process lost the ready race — exactly what stopVstSidecar() and preview.ts's shutdown paths exist to prevent. Track an in-flight `pending` promise, set synchronously before any spawn/callback work, so concurrent callers share the same startup attempt instead of double-spawning. Cleared via .finally() so a future call after this attempt settles (success or failure) can retry.