mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 14:50:02 +00:00
fix(render): avoid Windows output path limit for work dirs (#2479)
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
|||||||
isRecoverableParallelCaptureError,
|
isRecoverableParallelCaptureError,
|
||||||
MAX_TRANSIENT_CAPTURE_RETRIES,
|
MAX_TRANSIENT_CAPTURE_RETRIES,
|
||||||
resolveCaptureForceScreenshotForPageSideCompositing,
|
resolveCaptureForceScreenshotForPageSideCompositing,
|
||||||
|
resolveRenderWorkDirPrefix,
|
||||||
shouldDiscardProbeSessionForPageSideCompositing,
|
shouldDiscardProbeSessionForPageSideCompositing,
|
||||||
resolveInversionRetryPlan,
|
resolveInversionRetryPlan,
|
||||||
resolveParallelRouterRetryPlan,
|
resolveParallelRouterRetryPlan,
|
||||||
@@ -57,6 +58,16 @@ import {
|
|||||||
} from "./render/shared.js";
|
} from "./render/shared.js";
|
||||||
import { formatCaptureFrameName, toExternalAssetKey } from "../utils/paths.js";
|
import { formatCaptureFrameName, toExternalAssetKey } from "../utils/paths.js";
|
||||||
|
|
||||||
|
describe("resolveRenderWorkDirPrefix", () => {
|
||||||
|
it("uses a short system temp prefix on Windows instead of the output path", () => {
|
||||||
|
const outputPath = win32.join("C:\\deep", "nested".repeat(30), "renders", "final.mp4");
|
||||||
|
|
||||||
|
expect(resolveRenderWorkDirPrefix(outputPath, "long-render-job-id", "win32", "C:/Temp")).toBe(
|
||||||
|
join("C:/Temp", "hf-render-"),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("extractStandaloneEntryFromIndex", () => {
|
describe("extractStandaloneEntryFromIndex", () => {
|
||||||
it("reuses the index wrapper and keeps only the requested composition host", () => {
|
it("reuses the index wrapper and keeps only the requested composition host", () => {
|
||||||
const indexHtml = `<!DOCTYPE html>
|
const indexHtml = `<!DOCTYPE html>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import {
|
|||||||
copyFileSync,
|
copyFileSync,
|
||||||
appendFileSync,
|
appendFileSync,
|
||||||
} from "fs";
|
} from "fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
import { parseHTML } from "linkedom";
|
import { parseHTML } from "linkedom";
|
||||||
import { type CanvasResolution, type Fps, type FpsInput, toFps } from "@hyperframes/core";
|
import { type CanvasResolution, type Fps, type FpsInput, toFps } from "@hyperframes/core";
|
||||||
import {
|
import {
|
||||||
@@ -726,6 +727,16 @@ export function getNextRetryWorkerCount(currentWorkers: number): number {
|
|||||||
return Math.max(1, Math.floor(currentWorkers / 2));
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveRenderWorkDirPrefix(
|
||||||
|
outputPath: string,
|
||||||
|
jobId: string,
|
||||||
|
platform: NodeJS.Platform = process.platform,
|
||||||
|
systemTempDir: string = tmpdir(),
|
||||||
|
): string {
|
||||||
|
if (platform === "win32") return join(systemTempDir, "hf-render-");
|
||||||
|
return join(dirname(outputPath), `work-${jobId}-`);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bounded number of retries for transient browser deaths (a `Target closed` /
|
* Bounded number of retries for transient browser deaths (a `Target closed` /
|
||||||
* `Page crashed` — the tab died, not the composition). Distinct from the
|
* `Page crashed` — the tab died, not the composition). Distinct from the
|
||||||
@@ -1514,7 +1525,7 @@ export async function executeRenderJob(
|
|||||||
if (!existsSync(outputDir)) mkdirSync(outputDir, { recursive: true });
|
if (!existsSync(outputDir)) mkdirSync(outputDir, { recursive: true });
|
||||||
const workDir = job.config.debug
|
const workDir = job.config.debug
|
||||||
? join(debugDir, job.id)
|
? join(debugDir, job.id)
|
||||||
: mkdtempSync(join(outputDir, `work-${job.id}-`));
|
: mkdtempSync(resolveRenderWorkDirPrefix(outputPath, job.id));
|
||||||
const pipelineStart = Date.now();
|
const pipelineStart = Date.now();
|
||||||
const baseLog = job.config.logger ?? defaultLogger;
|
const baseLog = job.config.logger ?? defaultLogger;
|
||||||
const logPath = job.config.debug ? join(workDir, "render.log") : null;
|
const logPath = job.config.debug ? join(workDir, "render.log") : null;
|
||||||
|
|||||||
Reference in New Issue
Block a user