mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 00:56:23 +00:00
Address unanimous review feedback on PR #2095 (Miga, Magi REQUEST_CHANGES, Rames D Jusso): the router's process.env.HF_DE_PARALLEL_STREAM mutation was only cleared on the DE self-verify-retry branch — every other exit (happy path, any non-DE-verify error, abort) left it set, leaking the parallel-streaming opt-in into the next render sharing the same process (a regression/benchmark harness, or any batch host). Capture the prior value before mutating and restore it in the outer `finally` (executeRenderJob's own top-level try/finally, which runs on every exit path by construction), not just the narrow retry branch. Note `deParallelRouter` and the new `deParallelStreamEnvBefore` had to move above the outer `try` — a `let` declared inside `try {}` is not visible in the sibling `finally {}` block in JS, so the original placement alongside the other DE state would not have compiled once referenced from the finally. Also: renamed the shared `preInversionWorkerCount` local to `preRoutingWorkerCount` (Miga + Rames nit — it now serves both the inversion and the router), and pinned worker count 3 explicitly overrides calibration by design (documented per Miga/Rames's question, not a bug). Verified end-to-end (not just unit tests): ran two executeRenderJob calls back-to-back in one process, router-eligible then not — env is restored to undefined after render 1 and stays clean through render 2, the exact leak scenario the reviews described. 117 orchestrator tests pass (3 new, covering the restoreEnv primitive directly).