mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-14 18:01:20 +08:00
504e005287
StreamingEncoder.close() and closeCaptureSession() are both invoked from renderOrchestrator's HDR cleanup path with a tracked-flag pattern, but the outer finally block may still re-call them if the inner cleanup raised before the flag flipped. Both must therefore be idempotent. streamingEncoder.close: add an inline comment explaining why each step (clearTimeout, removeEventListener, stdin.end gated on !destroyed, shared exitPromise) is safe to repeat. closeCaptureSession: previously NOT truly idempotent under browser-pool semantics — releaseBrowser decrements pooledBrowserRefCount, so calling it twice for the same acquire could close a browser another session still holds. Add per-session pageReleased/browserReleased flags to the CaptureSession interface and gate page.close()/releaseBrowser() behind them. Set the flag AFTER the await so a mid-cleanup throw still allows the outer defensive call to retry the unreleased resource.