fix(render): retry explicit parallel capture timeouts (#2331)

This commit is contained in:
Miguel Ángel
2026-07-13 16:51:58 -04:00
committed by GitHub
parent e523a29f59
commit 5ff4ba13f4
2 changed files with 26 additions and 1 deletions
@@ -0,0 +1,12 @@
import { describe, expect, it } from "vitest";
import { shouldAllowAdaptiveCaptureRetry } from "./captureStage.js";
describe("shouldAllowAdaptiveCaptureRetry", () => {
it("keeps timeout recovery enabled when the initial worker count was explicit", () => {
expect(shouldAllowAdaptiveCaptureRetry(6, true)).toBe(true);
});
it("does not retry an already sequential capture", () => {
expect(shouldAllowAdaptiveCaptureRetry(1, true)).toBe(false);
});
});
@@ -133,6 +133,19 @@ export interface CaptureStageResult {
captureBeyondViewport?: boolean;
}
/**
* An explicit worker count selects the initial concurrency; it must not disable
* recovery after a worker times out. The adaptive loop only retries missing
* frames, requires forward progress, and halves workers until sequential, so it
* remains bounded while preserving already-captured work.
*/
export function shouldAllowAdaptiveCaptureRetry(
workerCount: number,
_explicitlyConfigured: boolean,
): boolean {
return workerCount > 1;
}
export async function runCaptureStage(input: CaptureStageInput): Promise<CaptureStageResult> {
const {
fileServer,
@@ -200,7 +213,7 @@ export async function runCaptureStage(input: CaptureStageInput): Promise<Capture
framesDir,
totalFrames,
initialWorkerCount: workerCount,
allowRetry: job.config.workers === undefined,
allowRetry: shouldAllowAdaptiveCaptureRetry(workerCount, job.config.workers !== undefined),
frameExt: needsAlpha ? "png" : "jpg",
captureOptions: buildCaptureOptions(),
createBeforeCaptureHook: createRenderVideoFrameInjector,