From db6b7478a7e66415b8c35da4126dcaee687026de Mon Sep 17 00:00:00 2001 From: wonjang <48057918+wonjangcloud9@users.noreply.github.com> Date: Sun, 15 Nov 2026 05:37:37 +0000 Subject: [PATCH] fix(engine): a failed parallel capture names the worker that failed, not the peers it stopped (#7803) When one capture worker fails, the pool aborts its peers and each of them reports "Parallel worker cancelled". The pool message listed every worker in id order, so the one real cause sat between cancellations: Worker 0: Parallel worker cancelled; Worker 1: Parallel worker cancelled; Worker 2: Disk capture may need ~2712.6 MB ...; Worker 3: Parallel worker cancelled The message now carries the failures that are not cancellations and counts the peers that were stopped because of them. A pool where every worker was cancelled keeps the full list. Co-authored-by: Claude Fable 5.2 --- .../parallelCoordinator-peerAbort.test.ts | 13 +++++--- .../src/services/parallelCoordinator.test.ts | 30 +++++++++++++++++++ .../src/services/parallelCoordinator.ts | 10 ++++++- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/packages/engine/src/services/parallelCoordinator-peerAbort.test.ts b/packages/engine/src/services/parallelCoordinator-peerAbort.test.ts index ad89b3b6a4..4dae2fa0b0 100644 --- a/packages/engine/src/services/parallelCoordinator-peerAbort.test.ts +++ b/packages/engine/src/services/parallelCoordinator-peerAbort.test.ts @@ -51,10 +51,15 @@ describe("executeParallelCapture peer abort", () => { () => null, ); - await expect(result).rejects.toMatchObject({ - name: "CaptureFailure", - kind: "authoring", - }); + const failure = await result.then( + () => undefined, + (error: unknown) => error, + ); + expect(failure).toMatchObject({ name: "CaptureFailure", kind: "authoring" }); + const message = (failure as Error).message; + expect(message).toContain("Worker 0: Composition has zero duration"); + expect(message).toContain("(1 other worker was stopped after this failure)"); + expect(message).not.toContain("Worker 1"); expect(captureFrame).not.toHaveBeenCalled(); expect(closeCaptureSession).toHaveBeenCalledTimes(2); } finally { diff --git a/packages/engine/src/services/parallelCoordinator.test.ts b/packages/engine/src/services/parallelCoordinator.test.ts index 8015015e8c..f381ea89a8 100644 --- a/packages/engine/src/services/parallelCoordinator.test.ts +++ b/packages/engine/src/services/parallelCoordinator.test.ts @@ -8,6 +8,7 @@ import { distributeFrames, expectedFramesForTask, flagSilentWorkerExits, + formatPoolFailure, formatWorkerFailure, isFfmpegInfrastructureFailure, isPoolFatalWorkerFailure, @@ -286,6 +287,35 @@ describe("worker failure diagnostics", () => { ]); }); + it("names the worker that failed and counts the peers it stopped", () => { + const worker = (workerId: number, failure: CaptureFailure): WorkerResult => ({ + workerId, + framesCaptured: 0, + startFrame: 0, + endFrame: 30, + durationMs: 10, + error: failure.message, + failure, + }); + const stopped = (workerId: number) => + worker( + workerId, + new CaptureFailure({ kind: "cancelled", message: "Parallel worker cancelled" }), + ); + const cause = worker(3, new CaptureFailure({ kind: "io", message: "disk is full" })); + + expect(formatPoolFailure([stopped(0), stopped(1), cause, stopped(4)])).toBe( + "Worker 3: disk is full (3 other workers were stopped after this failure)", + ); + expect(formatPoolFailure([cause, stopped(4)])).toBe( + "Worker 3: disk is full (1 other worker was stopped after this failure)", + ); + expect(formatPoolFailure([cause])).toBe("Worker 3: disk is full"); + expect(formatPoolFailure([stopped(0), stopped(1)])).toBe( + "Worker 0: Parallel worker cancelled; Worker 1: Parallel worker cancelled", + ); + }); + it("adds compact diagnostics to the worker failure message", () => { expect( formatWorkerFailure({ diff --git a/packages/engine/src/services/parallelCoordinator.ts b/packages/engine/src/services/parallelCoordinator.ts index ee07be145e..8b3c9f7d87 100644 --- a/packages/engine/src/services/parallelCoordinator.ts +++ b/packages/engine/src/services/parallelCoordinator.ts @@ -279,6 +279,14 @@ export function formatWorkerFailure(result: WorkerResult): string { return `${base}; diagnostics: ${diagnostics}`; } +export function formatPoolFailure(errors: WorkerResult[]): string { + const causes = errors.filter((result) => result.failure?.kind !== "cancelled"); + const stopped = errors.length - causes.length; + if (causes.length === 0 || stopped === 0) return errors.map(formatWorkerFailure).join("; "); + const peers = stopped === 1 ? "1 other worker was" : `${stopped} other workers were`; + return `${causes.map(formatWorkerFailure).join("; ")} (${peers} stopped after this failure)`; +} + /** Which constraint produced the final auto-sized worker count. */ export type WorkerSizingBound = | "explicit" @@ -1245,7 +1253,7 @@ export async function executeParallelCapture( const errors = results.filter((r) => r.failure || r.error); if (errors.length > 0) { - const errorMessages = errors.map(formatWorkerFailure).join("; "); + const errorMessages = formatPoolFailure(errors); const representative = failureHandler.firstFatalFailure() ?? errors.find((result) => result.failure)?.failure; const workerDiagnostics = errors.flatMap((result) => result.failure?.workerDiagnostics ?? []);