mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* fix(producer): a wedged effect scan or screenshot-session open trips the 60 s stall watchdog The sequential streaming watchdog raced only the capture call. Session init (where the fast-capture effect scan runs) and opening the screenshot session for effect frames waited on CDP's protocol timeout instead, which scales with output area up to 30 minutes, so a starved page hung a render for ~25 minutes before the watchdog saw the next frame. The effect scan now gives up when a chunk outlasts its 120 s budget, opening the effect-frame session gets its own no-progress window, and session init gets a 300 s one; each trip retries on a fresh session like any other stall. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(cli): one local render at a time per machine; a second waits and says for whom Renders started side by side from different sessions starve each other until frames stop landing. `hyperframes render` now takes a machine-wide slot (a lock file in the HyperFrames cache directory, held by pid) after its preflight and holds it for the render or the whole batch. A second render waits and prints the pid and project it is waiting behind; `--no-wait` fails at once instead. A holder whose process is gone is taken over, and HYPERFRAMES_RENDER_LOCK=off restores side-by-side renders. `--workers` is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(lint): flag fonts a cloud render cannot resolve, including the font shorthand Lint read only `font-family`, so `font: 500 16px "PingFang SC", sans-serif` passed while the renderer, which reads the shorthand too, drew the installed Mac font locally and the cloud refused it. The shorthand now counts for font_family_without_font_face (its parser moves to @hyperframes/parsers so core and lint share one), and a new font_face_local_only warning names an @font-face whose only sources are local(): it renders here and falls back in the cloud. The rule's hint and the format reference stop recommending local() for OS fonts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): a cloud render that refuses a font says which project files use it The cloud's "fonts that could not be resolved: PingFang SC" named no composition. For a render submitted from a local project, the failure now lists each refused family with the project files that name it, and says how to ship the font so the cloud can use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(cli): keep comment shares and exports within the gates, and split the single-render notes out of executeHeldRender Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(parsers): read a spaced line-height slash and var() before the size in the font shorthand `font: 16px / 1.5 Inter` was read as the family `/ 1.5 Inter`, and `font: var(--weight) 16px Inter` as `16px Inter`, because a var() counted as the size. The parser now follows the shorthand grammar: optional style, variant, weight and width keywords (or var()), then a length, percentage, keyword or calc() size, then a `/ line-height` in any spacing. When no size can be told apart from a var(), it says so: lint skips that declaration instead of reporting a missing font, and the renderer keeps its best guess. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): say the render slot is one per user account, not per machine The lock lives in the account's HyperFrames cache folder, so renders by two user accounts never queued behind each other while the messages, flag help and docs said "this machine". They now say "per user account" and that HYPERFRAMES_CACHE_DIR set to a shared folder shares the slot across accounts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): reclaim a render lock or takeover file left half-written A lock or `.break` file that exists but cannot be parsed (a crash mid-write where hard links are unavailable) was never reclaimed: a waiting render waited forever and --no-wait refused forever. Once such a file is older than any real write (5 s by mtime) it counts as abandoned: the lock goes through the same `.break` takeover as a dead holder's, and a takeover file is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(producer): opening the capture session counts against the setup stall budget The sequential streaming attempt opened its own capture session (Chrome launch and new page) before the setup watchdog and outside the attempt's cleanup, so a wedged launch still waited for the protocol timeout. Opening now shares the 300 s setup window with session initialisation, a trip fails the attempt like any other sequential stall, and a session that finishes opening after its attempt gave up is closed instead of leaking a browser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(parsers): keep the shorthand result type module-private Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): reclaim an unreadable render lock only when its writer is provably gone Where hard links are unavailable the lock is created by an exclusive open and then written, so a contender paused between the two leaves an unreadable lock while it is still alive. The 5 s mtime grace took such a lock over, and both processes then held the slot. Each contender now writes an owner marker under a name only it can take (pid plus random suffix, holding its process identity) before it creates the lock, keeps it while it holds the slot, and removes it otherwise. An unreadable lock or `.break` is reclaimed only when no other contender's marker belongs to a live process; markers of dead processes, or of a reused pid, are deleted. No reclaim is decided by time alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: split acquireRenderLock and the streaming-stage session stub under the complexity gate acquireRenderLock hands contender setup and a single marked claim to their own functions, and the test stub for createCaptureSession splits its held-open cases from the fake session it builds, so neither exceeds Fallow's cognitive or CRAP thresholds. Behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(ci): raise the CLI and engine size budgets for the watchdog, lock and font-lint additions Main's CLI unpacked size was already ~0.99% over its budget; the render lock and owner markers push it past the 1% tolerance. The CLI unpacked budget takes the same value as #7169 and #7170 (25,159,107) so the PRs merge cleanly. The engine's packed size grows by about 4.7 KB for the effect-scan and session-open watchdogs; its packed budget moves to 5% above the measured 467,097, as the budget file's headroom rule sets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(parsers): a var() size glued to its line height is the shorthand's size `font: 700 var(--size)/1.1 "Inter"` read as no family at all: the token was tested whole against var(), and the slash after it hid that it was the size, so the renderer injected no face for Inter. A var() followed by `/ line-height` (glued or spaced) can only be the size, and is now read as one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(parsers): split the shorthand size search out of parseFontShorthand Keeps parseFontShorthand under Fallow's cognitive-complexity gate; behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cli): render lock never removes another render's takeover, knows a reused pid, works in a shared folder and on Windows - A `.break` takeover file is removed only by the render that wrote it. One whose writer is gone stops the render with the file to delete, instead of being removed on an earlier reading, which could remove a live `.break` written since and let two renders hold the slot. The takeover re-reads the lock under its own `.break` right before replacing it. - The lock record keeps its holder's process start time, so a pid that now belongs to another process (an OOM-killed render in a container with a persisted cache) no longer holds the slot forever. - The `locks` folder is created writable for every account, so accounts sharing HYPERFRAMES_CACHE_DIR take turns instead of the second failing with EACCES; a folder this account cannot write in says how to fix it, and another account's file that cannot be removed is left, not fatal. - Windows: no PowerShell start-time lookup per check (pid liveness only), a file another handle holds (EPERM/EBUSY/EACCES) reads as held, a lock that vanished is retried once instead of in a tight loop, and a wait stops when its signal aborts. The tests end every acquire they start before removing their folder, and the paused contender writes through its open descriptor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(ci): raise the lint packed size budget for the font-shorthand rule With main's audio-attribute rule (#7169) merged in, the font-shorthand and local()-only font findings take @hyperframes/lint's packed tarball to 181925 bytes, over the 179338 budget. The new budget is that measurement plus the usual 5% headroom. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
421 lines
15 KiB
TypeScript
421 lines
15 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import {
|
|
chmodSync,
|
|
closeSync,
|
|
existsSync,
|
|
mkdirSync,
|
|
mkdtempSync,
|
|
openSync,
|
|
readdirSync,
|
|
readFileSync,
|
|
rmSync,
|
|
statSync,
|
|
writeFileSync,
|
|
} from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { acquireRenderLock, RenderLockBusy, type RenderLockOptions } from "./renderLock.js";
|
|
import { type RenderLockHolder } from "./renderLockClaim.js";
|
|
import { startToken } from "./renderLockOwners.js";
|
|
import { RenderLockStaleBreak } from "./renderLockClaim.js";
|
|
import type { Holder } from "./projectLock.js";
|
|
import { acquireRenderSlot } from "../commands/render/renderSlot.js";
|
|
|
|
let dir: string;
|
|
let path: string;
|
|
|
|
beforeEach(() => {
|
|
dir = mkdtempSync(join(tmpdir(), "hf-render-lock-"));
|
|
path = join(dir, "locks", "render.lock");
|
|
});
|
|
|
|
const stillWaiting: Array<{ stop: AbortController; settled: Promise<unknown> }> = [];
|
|
|
|
/** An acquire that every test ends before its folder is removed, so no loop outlives the test. */
|
|
function startAcquire(options: Omit<RenderLockOptions, "signal">): Promise<() => void> {
|
|
const stop = new AbortController();
|
|
const acquiring = acquireRenderLock({ ...options, signal: stop.signal });
|
|
stillWaiting.push({ stop, settled: acquiring.catch(() => undefined) });
|
|
return acquiring;
|
|
}
|
|
|
|
afterEach(async () => {
|
|
for (const { stop } of stillWaiting) stop.abort(new Error("test over"));
|
|
await Promise.all(stillWaiting.splice(0).map(({ settled }) => settled));
|
|
vi.useRealTimers();
|
|
vi.restoreAllMocks();
|
|
rmSync(dir, { recursive: true, force: true });
|
|
});
|
|
|
|
const deadPid = () => spawnSync(process.execPath, ["-e", ""]).pid;
|
|
|
|
describe("acquireRenderLock", () => {
|
|
it("refuses a second render under --no-wait, naming the render that holds the slot", async () => {
|
|
const release = await acquireRenderLock({ project: "/work/brand", wait: false, path, env: {} });
|
|
|
|
const second = acquireRenderLock({ project: "/work/crime", wait: false, path, env: {} });
|
|
|
|
await expect(second).rejects.toBeInstanceOf(RenderLockBusy);
|
|
await expect(second).rejects.toThrow(`pid ${process.pid}, project /work/brand`);
|
|
release();
|
|
expect(existsSync(path)).toBe(false);
|
|
});
|
|
|
|
it("waits while another render holds the slot and starts once it is released", async () => {
|
|
vi.useFakeTimers();
|
|
const release = await acquireRenderLock({ project: "/work/brand", wait: false, path, env: {} });
|
|
const waits: Array<RenderLockHolder | null> = [];
|
|
let started = false;
|
|
const second = startAcquire({
|
|
project: "/work/crime",
|
|
wait: true,
|
|
path,
|
|
env: {},
|
|
onWait: (holder) => waits.push(holder),
|
|
}).then((releaseSecond) => {
|
|
started = true;
|
|
return releaseSecond;
|
|
});
|
|
|
|
await vi.advanceTimersByTimeAsync(10_000);
|
|
expect(started).toBe(false);
|
|
expect(waits.map((holder) => holder?.project)).toEqual(["/work/brand"]);
|
|
|
|
release();
|
|
await vi.advanceTimersByTimeAsync(1_000);
|
|
expect(started).toBe(true);
|
|
(await second)();
|
|
});
|
|
|
|
it("takes over a slot whose render process is gone", async () => {
|
|
const stale: RenderLockHolder = {
|
|
pid: deadPid(),
|
|
command: "render",
|
|
startedAt: 1,
|
|
project: "/work/killed",
|
|
};
|
|
await acquireRenderLock({ project: "/work/seed", wait: false, path, env: {} }).then((r) => r());
|
|
writeFileSync(path, JSON.stringify(stale));
|
|
|
|
const release = await acquireRenderLock({ project: "/work/next", wait: false, path, env: {} });
|
|
|
|
release();
|
|
});
|
|
|
|
describe("a takeover file (.break)", () => {
|
|
const record = (pid: number, project: string): RenderLockHolder => ({
|
|
pid,
|
|
command: "render",
|
|
startedAt: 1,
|
|
project,
|
|
identity: startToken(pid),
|
|
});
|
|
const seed = (breaker: string) => {
|
|
mkdirSync(join(dir, "locks"), { recursive: true });
|
|
writeFileSync(path, JSON.stringify(record(deadPid(), "/work/killed")));
|
|
writeFileSync(`${path}.break`, breaker);
|
|
};
|
|
|
|
it.each([
|
|
["readable", () => JSON.stringify(record(deadPid(), "/work/breaker"))],
|
|
["half-written", () => '{"pid":'],
|
|
])(
|
|
"left %s by a render that died is never deleted on an earlier reading; the render says what to delete",
|
|
async (_kind, content) => {
|
|
const left = content();
|
|
seed(left);
|
|
for (const wait of [false, true]) {
|
|
await expect(
|
|
startAcquire({ project: "/work/next", wait, path, env: {} }),
|
|
).rejects.toBeInstanceOf(RenderLockStaleBreak);
|
|
}
|
|
expect(readFileSync(`${path}.break`, "utf8")).toBe(left);
|
|
},
|
|
);
|
|
|
|
it("that a live render is still writing is left to it, and that render's takeover holds alone", async () => {
|
|
vi.useFakeTimers({ now: Date.now() });
|
|
mkdirSync(join(dir, "locks"), { recursive: true });
|
|
writeFileSync(path, JSON.stringify(record(deadPid(), "/work/killed")));
|
|
let resume: () => void = () => {};
|
|
let heldBy: string[] = [];
|
|
const first = startAcquire({
|
|
project: "/work/one",
|
|
wait: false,
|
|
path,
|
|
env: {},
|
|
beforeReplace: () => new Promise<void>((resolve) => (resume = resolve)),
|
|
}).then((release) => ((heldBy = [...heldBy, "one"]), release));
|
|
await vi.waitFor(() => expect(existsSync(`${path}.break`)).toBe(true));
|
|
const breakWhileReplacing = readFileSync(`${path}.break`, "utf8");
|
|
|
|
await expect(
|
|
startAcquire({ project: "/work/two", wait: false, path, env: {} }),
|
|
).rejects.toBeInstanceOf(RenderLockBusy);
|
|
const second = startAcquire({ project: "/work/two", wait: true, path, env: {} }).then(
|
|
(release) => ((heldBy = [...heldBy, "two"]), release),
|
|
);
|
|
await vi.advanceTimersByTimeAsync(30_000);
|
|
expect(readFileSync(`${path}.break`, "utf8")).toBe(breakWhileReplacing);
|
|
expect(heldBy).toEqual([]);
|
|
|
|
resume();
|
|
const releaseFirst = await first;
|
|
await vi.advanceTimersByTimeAsync(5_000);
|
|
expect(heldBy).toEqual(["one"]);
|
|
releaseFirst();
|
|
await vi.advanceTimersByTimeAsync(1_000);
|
|
expect(heldBy).toEqual(["one", "two"]);
|
|
(await second)();
|
|
});
|
|
});
|
|
|
|
it.skipIf(process.platform === "win32")(
|
|
"takes over a lock whose pid now belongs to a different process",
|
|
async () => {
|
|
mkdirSync(join(dir, "locks"), { recursive: true });
|
|
const reused: RenderLockHolder = {
|
|
pid: process.pid,
|
|
command: "render",
|
|
startedAt: 1,
|
|
project: "/work/oom-killed",
|
|
identity: "linux:1",
|
|
};
|
|
writeFileSync(path, JSON.stringify(reused));
|
|
|
|
const release = await acquireRenderLock({
|
|
project: "/work/next",
|
|
wait: false,
|
|
path,
|
|
env: {},
|
|
});
|
|
|
|
expect(JSON.parse(readFileSync(path, "utf8")).project).toBe("/work/next");
|
|
release();
|
|
},
|
|
);
|
|
|
|
describe.skipIf(process.platform === "win32")("a cache folder shared by accounts", () => {
|
|
it("creates its locks folder writable for every account", async () => {
|
|
const release = await acquireRenderLock({ project: "/work/a", wait: false, path, env: {} });
|
|
expect(statSync(join(dir, "locks")).mode & 0o777).toBe(0o777);
|
|
release();
|
|
});
|
|
|
|
it.skipIf(process.getuid?.() === 0)(
|
|
"says how to fix a locks folder this account cannot write in",
|
|
async () => {
|
|
mkdirSync(join(dir, "locks"), { mode: 0o755 });
|
|
chmodSync(join(dir, "locks"), 0o555);
|
|
try {
|
|
await expect(
|
|
acquireRenderLock({ project: "/work/b", wait: false, path, env: {} }),
|
|
).rejects.toThrow(`chmod 777 ${join(dir, "locks")}`);
|
|
} finally {
|
|
chmodSync(join(dir, "locks"), 0o755);
|
|
}
|
|
},
|
|
);
|
|
});
|
|
|
|
it("keeps the slot in this user's HyperFrames cache folder, which HYPERFRAMES_CACHE_DIR can share", async () => {
|
|
vi.stubEnv("HYPERFRAMES_CACHE_DIR", join(dir, "shared"));
|
|
try {
|
|
const release = await acquireRenderLock({ project: "/work/brand", wait: false, env: {} });
|
|
expect(existsSync(join(dir, "shared", "locks", "render.lock"))).toBe(true);
|
|
release();
|
|
} finally {
|
|
vi.unstubAllEnvs();
|
|
}
|
|
});
|
|
|
|
describe("a lock file that cannot be read yet", () => {
|
|
/** A contender that opens the lock exclusively, then stalls before writing its holder. */
|
|
const pausedAfterOpen = (gate: Promise<void>) => async (file: string, holder: Holder) => {
|
|
const fd = openSync(file, "wx");
|
|
await gate;
|
|
writeFileSync(fd, JSON.stringify(holder));
|
|
closeSync(fd);
|
|
return true;
|
|
};
|
|
|
|
it("is not taken from a live contender paused between opening and writing it", async () => {
|
|
vi.useFakeTimers({ now: Date.now() });
|
|
let resume: () => void = () => {};
|
|
const writerA = startAcquire({
|
|
project: "/work/a",
|
|
wait: false,
|
|
path,
|
|
env: {},
|
|
claim: pausedAfterOpen(new Promise<void>((resolve) => (resume = resolve))),
|
|
});
|
|
let heldByB = false;
|
|
const writerB = startAcquire({ project: "/work/b", wait: true, path, env: {} }).then(
|
|
(release) => {
|
|
heldByB = true;
|
|
return release;
|
|
},
|
|
);
|
|
|
|
await vi.advanceTimersByTimeAsync(60_000);
|
|
expect(heldByB).toBe(false);
|
|
await expect(
|
|
acquireRenderLock({ project: "/work/c", wait: false, path, env: {} }),
|
|
).rejects.toBeInstanceOf(RenderLockBusy);
|
|
|
|
resume();
|
|
const releaseA = await writerA;
|
|
await vi.advanceTimersByTimeAsync(5_000);
|
|
expect(heldByB).toBe(false);
|
|
releaseA();
|
|
await vi.advanceTimersByTimeAsync(1_000);
|
|
expect(heldByB).toBe(true);
|
|
(await writerB)();
|
|
});
|
|
|
|
it("is reclaimed when the contender that opened it died before writing", async () => {
|
|
let crash: (reason: Error) => void = () => {};
|
|
const died = new Promise<void>((_, reject) => (crash = reject));
|
|
const writerA = startAcquire({
|
|
project: "/work/a",
|
|
wait: false,
|
|
path,
|
|
env: {},
|
|
pid: deadPid(),
|
|
// A dead process holds no handle, so the opened file is closed, as the OS would close it.
|
|
claim: async (file) => {
|
|
closeSync(openSync(file, "wx"));
|
|
await died;
|
|
return true;
|
|
},
|
|
});
|
|
await vi.waitFor(() => expect(existsSync(path)).toBe(true));
|
|
|
|
const release = await acquireRenderLock({ project: "/work/b", wait: false, path, env: {} });
|
|
|
|
expect(readdirSync(join(dir, "locks")).filter((n) => n.includes(".owner-"))).toHaveLength(1);
|
|
release();
|
|
expect(readdirSync(join(dir, "locks"))).toEqual([]);
|
|
crash(new Error("A is gone"));
|
|
await expect(writerA).rejects.toThrow("A is gone");
|
|
});
|
|
|
|
it("is reclaimed when no contender is left at all", async () => {
|
|
mkdirSync(join(dir, "locks"), { recursive: true });
|
|
writeFileSync(path, '{"pid":');
|
|
|
|
const release = await acquireRenderLock({
|
|
project: "/work/next",
|
|
wait: false,
|
|
path,
|
|
env: {},
|
|
});
|
|
|
|
release();
|
|
expect(existsSync(path)).toBe(false);
|
|
});
|
|
});
|
|
|
|
it("stops waiting, and stops marking itself a contender, when its signal aborts", async () => {
|
|
vi.useFakeTimers();
|
|
const release = await acquireRenderLock({ project: "/work/brand", wait: false, path, env: {} });
|
|
const stop = new AbortController();
|
|
const waiting = acquireRenderLock({
|
|
project: "/work/crime",
|
|
wait: true,
|
|
path,
|
|
env: {},
|
|
signal: stop.signal,
|
|
});
|
|
await vi.advanceTimersByTimeAsync(3_000);
|
|
|
|
stop.abort(new Error("cancelled"));
|
|
await expect(waiting).rejects.toThrow("cancelled");
|
|
release();
|
|
await vi.advanceTimersByTimeAsync(5_000);
|
|
expect(readdirSync(join(dir, "locks"))).toEqual([]);
|
|
});
|
|
|
|
it("reads a file another handle holds (Windows EPERM/EBUSY) as held, not as a failure", async () => {
|
|
const busy = Object.assign(new Error("EBUSY: resource busy or locked"), { code: "EBUSY" });
|
|
|
|
await expect(
|
|
acquireRenderLock({
|
|
project: "/work/crime",
|
|
wait: false,
|
|
path,
|
|
env: {},
|
|
claim: () => {
|
|
throw busy;
|
|
},
|
|
}),
|
|
).rejects.toBeInstanceOf(RenderLockBusy);
|
|
expect(readdirSync(join(dir, "locks")).filter((n) => n.includes(".owner-"))).toEqual([]);
|
|
});
|
|
|
|
it("never starts PowerShell for a start-time lookup on Windows", () => {
|
|
const platform = Object.getOwnPropertyDescriptor(process, "platform")!;
|
|
Object.defineProperty(process, "platform", { ...platform, value: "win32" });
|
|
try {
|
|
expect(startToken(process.pid)).toBeNull();
|
|
} finally {
|
|
Object.defineProperty(process, "platform", platform);
|
|
}
|
|
});
|
|
|
|
it("lets renders run side by side with HYPERFRAMES_RENDER_LOCK=off", async () => {
|
|
const env = { HYPERFRAMES_RENDER_LOCK: "off" };
|
|
await acquireRenderLock({ project: "/work/brand", wait: false, path, env });
|
|
|
|
await expect(
|
|
acquireRenderLock({ project: "/work/crime", wait: false, path, env }),
|
|
).resolves.toBeTypeOf("function");
|
|
});
|
|
});
|
|
|
|
describe("acquireRenderSlot", () => {
|
|
it("fails the command under --no-wait and tells the person which render holds the slot", async () => {
|
|
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
const release = await acquireRenderLock({ project: "/work/brand", wait: false, path, env: {} });
|
|
|
|
await expect(
|
|
acquireRenderSlot(
|
|
{ project: { dir: "/work/crime" } as never, waitForRenderSlot: false },
|
|
undefined,
|
|
{ path, env: {} },
|
|
),
|
|
).rejects.toThrow("Command failed");
|
|
|
|
const said = vi.mocked(console.error).mock.calls.flat().join("\n");
|
|
expect(said).toContain("Another render is running for this user account");
|
|
expect(said).toContain("HYPERFRAMES_CACHE_DIR to a shared folder");
|
|
expect(said).toContain(`pid ${process.pid}, project /work/brand`);
|
|
release();
|
|
});
|
|
|
|
it("says who it is waiting for while it waits", async () => {
|
|
vi.useFakeTimers();
|
|
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
const release = await acquireRenderLock({ project: "/work/brand", wait: false, path, env: {} });
|
|
|
|
const stop = new AbortController();
|
|
const slot = acquireRenderSlot(
|
|
{ project: { dir: "/work/crime" } as never, waitForRenderSlot: true },
|
|
stop.signal,
|
|
{ path, env: {} },
|
|
);
|
|
stillWaiting.push({ stop, settled: slot.catch(() => undefined) });
|
|
await vi.advanceTimersByTimeAsync(3_000);
|
|
|
|
const said = vi.mocked(console.error).mock.calls.flat().join("\n");
|
|
expect(said).toContain(
|
|
`Waiting for another render to finish (pid ${process.pid}, project /work/brand`,
|
|
);
|
|
expect(said).toContain("one at a time per user account");
|
|
release();
|
|
await vi.advanceTimersByTimeAsync(1_000);
|
|
(await slot)();
|
|
});
|
|
});
|