Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions packages/cli/src/commands/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,67 @@ describe("renderLocal browser GPU config", () => {
}
});

it("does not suggest --docker when the render was cancelled", async () => {
let markExecutionStarted!: () => void;
const executionStarted = new Promise<void>((resolve) => {
markExecutionStarted = resolve;
});
producerState.executeImpl = async (_job, abortSignal) => {
markExecutionStarted();
await new Promise<void>((_resolve, reject) => {
abortSignal?.addEventListener("abort", () => reject(new Error("render_cancelled")), {
once: true,
});
});
};
const priorListeners = new Set(process.listeners("SIGTERM"));
const errors = vi.spyOn(console, "error").mockImplementation(() => {});
try {
const render = renderLocal(PROJECT_DIR, "/tmp/out.mp4", {
fps: { num: 30, den: 1 },
quality: "standard",
format: "mp4",
gpu: false,
browserGpuMode: "software",
hdrMode: "auto",
quiet: true,
});
await executionStarted;
process.listeners("SIGTERM").find((listener) => !priorListeners.has(listener))?.("SIGTERM");

await expect(render).rejects.toMatchObject({ name: "CliRuntimeError" });
const output = errors.mock.calls.map((call) => String(call[0])).join("\n");
expect(output).toContain("render_cancelled");
expect(output).not.toContain("--docker");
} finally {
errors.mockRestore();
}
});

it("still suggests --docker when a render fails on its own", async () => {
producerState.executeImpl = async () => {
throw new Error("Chrome crashed during capture");
};
const errors = vi.spyOn(console, "error").mockImplementation(() => {});
try {
await expect(
renderLocal(PROJECT_DIR, "/tmp/out.mp4", {
fps: { num: 30, den: 1 },
quality: "standard",
format: "mp4",
gpu: false,
browserGpuMode: "software",
hdrMode: "auto",
quiet: true,
}),
).rejects.toMatchObject({ name: "CliRuntimeError" });
const output = errors.mock.calls.map((call) => String(call[0])).join("\n");
expect(output).toContain("Try --docker for containerized rendering");
} finally {
errors.mockRestore();
}
});

it.each([
{ kind: "solid", rgb: [10, 46, 138] },
{ kind: "none" },
Expand Down
12 changes: 8 additions & 4 deletions packages/cli/src/commands/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,16 +1322,13 @@ async function executeLocalRender(
);
} catch (error: unknown) {
maybeConsumeDeParallelRouterTrial(deParallelRouterActive, job, options.quiet);
// The render container sets `ENV CONTAINER=true`; suggesting `--docker`
// from inside it is a misdirection (heygen-com/hyperframes#3370).
const inContainer = process.env.CONTAINER === "true";
handleRenderError(
error,
options,
startTime,
cpu,
false,
inContainer ? "" : "Try --docker for containerized rendering",
localRenderFailureHint(cancellation.signal.aborted),
job.failedStage,
job,
);
Expand Down Expand Up @@ -1988,6 +1985,13 @@ export function chromeLaunchFailure(
: null;
}

// A cancelled render has nothing to retry in a container, and inside the render
// container (`ENV CONTAINER=true`) the hint misleads (heygen-com/hyperframes#3370).
function localRenderFailureHint(cancelled: boolean): string {
if (cancelled || process.env.CONTAINER === "true") return "";
return "Try --docker for containerized rendering";
}

function handleRenderError(
error: unknown,
options: RenderOptions,
Expand Down
Loading