The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Worker: the face check never restarts ComfyUI under a job in hand
Adarsh7cac32630841
diff --git a/bin/lib/worker/run.mjs b/bin/lib/worker/run.mjsindex 6c5ea9ee..d1565b27 100644--- a/bin/lib/worker/run.mjs+++ b/bin/lib/worker/run.mjs@@ -70,6 +70,11 @@ const HOUR = 3_600_000;export const SELF_CHECK_RETRY_MS = 5_000;/** A face self-check that failed twice (once more after a restart of its ComfyUI): face jobs wait this long, then it checks again. */export const SELF_CHECK_PAUSE_MS = 5 * 60_000;+/**+ * A face self-check that times out less than this long after its last GPU job ended (or while its text slot answers on+ * the GPU) only waited for a busy GPU: it is "not checked yet", never a fault of its ComfyUI.+ */+export const FACE_SETTLE_MS = 60_000;/** How long the last counters read that worked stands in for one that failed. */export const COUNTERS_REUSE_MS = 90_000;/** Busy readings in a row (5 s apart) that only the GPU's total decided, before they pause the worker. */@@ -346,10 +351,17 @@ async function work(saved, deps, owner) {let comfyTrouble = null;let troubleAt = 0;// Its ComfyUI lists the nodes of its face detector's self-check (self-check.mjs), and how many checks it ran.- let faceNodes = false;+ let faceNodes = !!deps.faceNodes;let faceChecks = 0;// When a face self-check last failed twice: face jobs go back in line until SELF_CHECK_PAUSE_MS later; other jobs go on.let facesDownAt = null;+ // A face check it owes, done between jobs before its next claim: "check" (not checked yet: a job was in hand after a+ // start, or a check timed out on a busy GPU; once FACE_SETTLE_MS after its last GPU job) or "restart" (a check before+ // a face job failed: that job went back in line, and its ComfyUI may start again now that no job is in hand).+ let facesOwed = null;+ // When its last GPU job that reached its ComfyUI ended, and whether the job in hand passed its checks (so it runs).+ let gpuJobEndedAt = -Infinity;+ let jobVetted = false;let answer = null;let inv = { files: [], nodePacks: [], media: ffmpeg ? ["image", "video", "audio"] : ["image"] };let packs = [];@@ -512,7 +524,7 @@ async function work(saved, deps, owner) {return;}if (!info || typeof info !== "object" || !Object.keys(info).length) return;- faceNodes = !!info.H3FaceTrackCrop && !!info.PreviewAny;+ faceNodes = deps.faceNodes ?? (!!info.H3FaceTrackCrop && !!info.PreviewAny);const fresh = loadedPacks(packs, index, info);for (const [name, l] of Object.entries(fresh)) {if (!l.missing.length || JSON.stringify(loaded[name]) === JSON.stringify(l)) continue;@@ -526,22 +538,46 @@ async function work(saved, deps, owner) {inv = { ...inv, nodePacks: packsAsSeen(packs, loaded) };invHash = inventoryHash(inv);}+ // Its GPU is busy for a face check: its last GPU job ended less than FACE_SETTLE_MS ago, or its text slot answers there.+ const faceSettleMs = deps.faceSettleMs ?? FACE_SETTLE_MS;+ const faceGpuBusy = () => now() - gpuJobEndedAt < faceSettleMs || (!!text?.busy && text.server?.device === "gpu");/*** Its face detector's self-check (self-check.mjs) on its GPU ComfyUI, while that ComfyUI has the face nodes. A failure* starts its ComfyUI again and checks once more; a second failure holds back face jobs only (they go back in line,* "self-check") for SELF_CHECK_PAUSE_MS (5 minutes), while every other job goes on. True when it passed, or when there* is nothing to check.+ *+ * Its ComfyUI is never started again under a GPU job in hand: after a start with a job in hand it checks once that job+ * has ended; before a face job, a failure gives that job back and its ComfyUI starts again between jobs. A check that+ * times out on a busy GPU (FACE_SETTLE_MS) is "not checked yet": checked again between jobs, never held against it.+ * `o.start`: the check after a start; `o.job`: the check before a job in hand (false: that job goes back in line).*/- async function checkFaces(when) {+ async function checkFaces(when, o = {}) {if (!faceNodes || !comfy.ready) return true;if (facesDownAt !== null) {if (now() - facesDownAt < SELF_CHECK_PAUSE_MS) return false;facesDownAt = null;}- const once = () => runSelfCheck((url, init) => comfy.fetch(url, init), comfy.base, { n: ++faceChecks, now, sleep });+ const inHand = () => busyJob && jobUsesGpu;+ if (o.start && inHand()) {+ facesOwed ??= "check";+ log(`Its face check ${when} waits: a job is in hand, and it checks once that job has ended.`);+ return true;+ }+ const notYet = () => {+ facesOwed ??= "check";+ log(`Its face check ${when} timed out while its GPU was busy: not checked yet, and it checks again between jobs${o.job ? " (this face job goes back in line)" : ""}.`);+ return !o.job;+ };+ const passed = () => {+ facesOwed = null;+ return true;+ };+ const once = () => (deps.selfCheck ?? runSelfCheck)((url, init) => comfy.fetch(url, init), comfy.base, { n: ++faceChecks, now, sleep });const read = (r) => `${r.height === null ? "no face" : `${Math.round(r.height)} px`} (${r.why}${r.detail ? `: ${r.detail}` : ""})`;let first = await once();- if (first.ok) return true;+ if (first.ok) return passed();+ if (first.why === "timeout" && faceGpuBusy()) return notYet();// A check that didn't run to the end (its graph failed, its photo didn't upload, it timed out) is often a ComfyUI// that has only just started: one more try after a few seconds, before it is started again.if (first.why !== "height" && first.why !== "no-report") {@@ -550,8 +586,15 @@ async function work(saved, deps, owner) {first = await once();if (first.ok) {log(`Its face check passed on the second try (${Math.round(first.height)} px).`);- return true;+ return passed();}+ if (first.why === "timeout" && faceGpuBusy()) return notYet();+ }+ // A job in hand (the face job this check is for): it goes back in line, and its ComfyUI starts again between jobs.+ if (inHand()) {+ facesOwed = "restart";+ log(`Its face check ${when} read ${read(first)}: this job goes back in line, and its ComfyUI starts again once no job is in hand.`);+ return false;}log(`Its face check ${when} read ${read(first)}: starting its ComfyUI again.`);// While it starts again, the loop starts no ComfyUI of its own (a start under way already holds `starting`).@@ -574,8 +617,9 @@ async function work(saved, deps, owner) {const second = comfy.ready ? await once() : { ok: false, height: null, why: "no-comfy" };if (second.ok) {log(`Its face check passed after the restart (${Math.round(second.height)} px).`);- return true;+ return passed();}+ facesOwed = null;facesDownAt = now();log(`Its face check failed again after the restart (${second.why}${second.detail ? `: ${second.detail}` : ""}): face jobs go back in line for ${Math.round(SELF_CHECK_PAUSE_MS / 60_000)} minutes, then it checks again first; other jobs go on.`);return false;@@ -708,7 +752,8 @@ async function work(saved, deps, owner) {log(`Refused job ${t.id}: ${problem.reason} at node ${problem.node}${problem.cls ? ` (${problem.cls}${problem.input ? `.${problem.input}` : ""})` : ""}.`);return problem.reason;}- if (o.faces && detectsFaces(t.graph) && !(await checkFaces("before a face job"))) return { giveBack: "self-check" };+ if (o.faces && detectsFaces(t.graph) && !(await checkFaces("before a face job", { job: true }))) return { giveBack: "self-check" };+ if (o.faces) jobVetted = true;return null;}@@ -1019,6 +1064,7 @@ async function work(saved, deps, owner) {const take = (o) => {busyJob = true;jobUsesGpu = !o?.onlyHeld;+ jobVetted = false;// Other programs use the PC's memory (its RAM guard): a claim prefers no job that streams from RAM.job = runner.claimAndRun(!o?.onlyHeld && ramOn && ramWatch.over ? { ...o, noStream: true } : o)@@ -1029,6 +1075,9 @@ async function work(saved, deps, owner) {}).catch((e) => log(comfy.task ? `A job stopped: ${failure(e)}` : `It can't ask the studio for a job: ${failure(e)}`)).finally(() => {+ // A job that went to its ComfyUI: a face check just after it may still meet a busy GPU (FACE_SETTLE_MS).+ if (jobVetted) gpuJobEndedAt = now();+ jobVetted = false;busyJob = false;jobUsesGpu = false;comfy.task = null;@@ -1320,7 +1369,8 @@ async function work(saved, deps, owner) {{ signal: stopStarts.signal },).then(() => readLoadedNodes())- .then(() => checkFaces("after its start"))+ // Its face check comes before its first claim: no claim while `starting` holds.+ .then(() => checkFaces("after its start", { start: true })).catch((e) => {if (stopStarts.signal.aborted) return;if (e instanceof PortBusy) {@@ -1337,7 +1387,13 @@ async function work(saved, deps, owner) {.finally(() => (starting = null));}}- if (comfy.ready && answer?.runner && !busyJob && !holdBack && !heldFirst && claimDue(t, gpuMissedAt, siteOf(answer).claimable ?? 0, idleClaimMs)) take();+ // A face check it owes, between jobs and before its next claim (it holds `starting`, so no claim meanwhile).+ if (facesOwed && facesDownAt === null && comfy.ready && !starting && !busyJob && (facesOwed === "restart" || !faceGpuBusy())) {+ starting = checkFaces("between jobs")+ .catch((e) => log(`Its face check between jobs didn't run: ${e.message}`))+ .finally(() => (starting = null));+ }+ if (comfy.ready && !starting && answer?.runner && !busyJob && !holdBack && !heldFirst && claimDue(t, gpuMissedAt, siteOf(answer).claimable ?? 0, idleClaimMs)) take();} else if (comfy.alive() && (stopNow || !busyJob)) {log("Stopping its own ComfyUI (paused).");await comfy.stop();@@ -1386,7 +1442,7 @@ async function work(saved, deps, owner) {if (updating) why = "updating";else if ((busyJob && jobUsesGpu) || !mayWork() || !answer?.runner) why = null;else if (heldFirst || busyJob) why = "sending-kept";- else if (!comfy.ready) why = "starting-comfy";+ else if (!comfy.ready || starting) why = "starting-comfy";else if (turn.waitForYield) why = "waiting-for-yield";else if (gpu.busyInARow > 0) why = "gpu-check";else if (holdBack) why = "local-work";diff --git a/docs/gpu-workers.md b/docs/gpu-workers.mdindex 73790bd9..6fedf13f 100644--- a/docs/gpu-workers.md+++ b/docs/gpu-workers.md@@ -871,7 +871,17 @@ takes about a second.- The worker checks after each start of its ComfyUI, and before each job that has `H3FaceTrackCrop` or`H3FaceSelect`. It checks only when its ComfyUI lists `H3FaceTrackCrop` and `PreviewAny`.-- When a check fails, the worker starts its ComfyUI again and checks once more.+- The check after a start comes before the worker's first claim: it takes no job until that check has passed or+ given up. If a job was already in hand (its ComfyUI stopped during the job and started again), the worker does not+ check under that job. It checks between jobs, once the job has ended.+- The worker never starts its ComfyUI again under a job in hand. When the check before a face job fails, that job+ goes back in line with its place kept, and the try does not count against it (give-back `self-check`). Then, with no+ job in hand, the worker checks again before its next claim, and starts its ComfyUI again if that check fails too.+- A check that times out while the GPU is busy is "not checked yet", not a fault of its ComfyUI. Busy means: its last+ GPU job ended less than a minute ago, or its text slot answers a text job on the GPU. The worker does not start its+ ComfyUI again and does not hold back face jobs. A face job in hand goes back in line the same way, and the worker+ checks again between jobs once the GPU has settled.+- When a check fails with no job in hand, the worker starts its ComfyUI again and checks once more.- When the second check fails too, the job goes back in line with its place kept, and the try does not count againstit (give-back `self-check`). For 5 minutes after that, every face job it is given goes back in line the same way,without a check. Every other job goes on as usual: its ComfyUI keeps running. After the 5 minutes, the next face jobdiff --git a/tests/worker-face-check-run.test.ts b/tests/worker-face-check-run.test.tsnew file mode 100644index 00000000..8aa93c29--- /dev/null+++ b/tests/worker-face-check-run.test.ts@@ -0,0 +1,263 @@+/**+ * The worker's face self-check in its run (bin/lib/worker/run.mjs), end to end against the studio's real routes and its+ * own stand-in ComfyUI (tests/helpers/fake-local-comfy.ts, a process of its own). The check itself is a stand-in+ * (deps.selfCheck), so each test says what it reads; the detector's own check is in tests/worker-self-check.test.ts.+ *+ * - The check after its ComfyUI starts runs before its first claim.+ * - Its ComfyUI stops under a running job and comes back: no check (and no restart) under that job, and the job ends;+ * the check it owes runs between jobs.+ * - A check before a face job fails: that job goes back in line (never failed), its ComfyUI starts again with no job in+ * hand, and the job then runs.+ * - A check that times out just after a job is "not checked yet": no restart, no 5-minute hold.+ */+import fs from "node:fs";+import path from "node:path";+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";+import { runWorker } from "../bin/lib/worker/run.mjs";+import { inputRules, readCatalog } from "../scripts/lib/worker-catalog.mjs";+import { FAKE_PNG } from "./helpers/fake-local-comfy";+import { apiAs, loadRoutes, type ComputerRoutes } from "./helpers/computer-tab";+import { tempDir } from "./helpers/temp-dir";++vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));+vi.setConfig({ testTimeout: 120_000 });++const dir = tempDir("fuobe-worker-face-run-");+process.env.FUOBE_DATA_DIR = dir;+process.env.COMFYUI_URL = "http://owner-comfy.test:8188";+delete process.env.FUOBE_PASSWORD;+globalThis.__fuobeTestDiskFree = 1e13;++const { db } = await import("@/server/db");+const { resetRates } = await import("@/server/rate");+const { setSetting } = await import("@/server/settings");+const tasks = await import("@/server/computer/tasks");+const pool = await import("@/server/computer/pool");+const { ComputerRunner } = await import("@/lib/computer-runner");++const ROOT = path.resolve(__dirname, "..");+const FAKE = path.join(ROOT, "tests/helpers/fake-local-comfy.ts");+const SITE = "http://127.0.0.1:9";+const RULES = inputRules(readCatalog(ROOT));+const ALLOWED = new Set(["LoadImage", "KSampler", "SaveImage", "H3FaceTrackCrop"]);+const realFetch = globalThis.fetch;+const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));++let routes: ComputerRoutes;+beforeAll(async () => {+ routes = await loadRoutes();+ setSetting("comfyWhere", "workers");+});+beforeEach(() => {+ resetRates();+ db().prepare("DELETE FROM relay_workers").run();+ db().prepare("UPDATE relay_tasks SET state = 'canceled' WHERE state IN ('waiting','sending','queued','running','collecting')").run();+});+const running: { ctrl: AbortController; done: Promise<unknown> }[] = [];+afterEach(async () => {+ for (const r of running.splice(0)) {+ r.ctrl.abort();+ await r.done.catch(() => {});+ }+});++type W = { id: string; token: string };+const task = (id: string) => db().prepare("SELECT * FROM relay_tasks WHERE id = ?").get(id) as import("@/server/computer/tasks").TaskRow;++function addWorker(): W {+ const w = pool.addWorker(`face-${Math.random().toString(36).slice(2, 8)}`);+ pool.patchWorker(w.id, { paused: false, hours: { always: true }, allow: { small: { delayMs: 0 } } });+ db().prepare("UPDATE relay_workers SET lanes_json = ?, facts_json = ? WHERE id = ?").run(JSON.stringify({ lanes: ["small"], workflows: ["wf-test"] }), JSON.stringify({ vramBytes: 24 * 2 ** 30 }), w.id);+ return w;+}++let gens = 0;+/** A job that loads a picture and saves one; `face`: it detects faces too (a face job). */+function addTask(o: { face?: boolean } = {}): string {+ const gid = `face-gen-${++gens}`;+ const now = Date.now();+ db()+ .prepare("INSERT INTO generations (id, feature, model_id, engine, provider, op, kind, status, request_json, outputs_json, created_at, updated_at) VALUES (?, 'image', 'm', 'open', 'comfyui', 't2i', 'image', 'queued', '{}', '[]', ?, ?)")+ .run(gid, now, now);+ const input = tasks.stageInput("owner", FAKE_PNG, "image/png", "in.png");+ return tasks.createTask({+ principal: "owner",+ generationId: gid,+ graph: {+ "1": { class_type: "LoadImage", inputs: { image: input } },+ ...(o.face && { "2": { class_type: "H3FaceTrackCrop", inputs: { images: ["1", 0], detector: "bbox\\face_yolov8m.pt", fallback_detector: "none" } } }),+ "3": { class_type: "KSampler", inputs: { seed: 1, steps: 4 } },+ "9": { class_type: "SaveImage", inputs: { images: ["1", 0], filename_prefix: "fuobe/worker-test" } },+ },+ pool: { pools: ["pool"], rankAt: now, lane: "small", needs: { workflowId: "wf-test", files: [], packs: [], minVramBytes: 0 } },+ }).id;+}++type Check = { ok: boolean; height: number | null; why?: string };+const PASS: Check = { ok: true, height: 168 };++interface Pc {+ workDir: string;+ logs: string[];+ /** When each claim went to the studio. */+ claims: number[];+ reports: Record<string, unknown>[];+ /** Each face check the worker ran: when it began and ended. */+ checks: { from: number; to: number; read: Check }[];+}++/** Start `fuobe worker run` here; `read(n)` says what its n-th face check (from 1) reads, after `checkMs`. */+function start(w: W, o: { read: (n: number) => Check; checkMs?: number; steps?: number; stepMs?: number; faceSettleMs?: number }): Pc {+ const base = tempDir("fuobe-worker-face-pc-");+ const dirs = { home: path.join(base, "home"), workDir: path.join(base, "work"), comfyDir: path.join(base, "comfy") };+ for (const d of Object.values(dirs)) fs.mkdirSync(d, { recursive: true });+ const p: Pc = { workDir: dirs.workDir, logs: [], claims: [], reports: [], checks: [] };+ const api = apiAs(routes, null);+ const ctrl = new AbortController();+ const done = runWorker(+ {+ site: SITE,+ token: w.token,+ comfyDir: dirs.comfyDir,+ workDir: dirs.workDir,+ modelDirs: [],+ comfyCommand: [process.execPath, "--disable-warning=MODULE_TYPELESS_PACKAGE_JSON", FAKE, "--port", "{port}", "--cors", "off", "--steps", String(o.steps ?? 4), "--step-ms", String(o.stepMs ?? 40), "--worker-guard", "1"],+ comfyGuard: true,+ ffmpeg: null,+ },+ {+ fetch: async (url: string, init: RequestInit = {}) => {+ if (!String(url).startsWith(SITE)) return realFetch(url, init);+ const u = new URL(url);+ if (u.pathname === "/api/gpu/computer/inventory") return Response.json({ ok: true, lanes: ["small"], workflows: ["wf-test"], missing: [] });+ if (u.pathname === "/api/gpu/computer/claim") p.claims.push(Date.now());+ if (u.pathname.endsWith("/report")) p.reports.push(JSON.parse(String(init.body)));+ return api(u.pathname + u.search, init);+ },+ home: dirs.home,+ signal: ctrl.signal,+ requirements: { folders: [], files: {}, packs: {}, workflows: {} },+ ComputerRunner,+ rules: RULES,+ pins: {},+ allowed: ALLOWED,+ ffmpegVersion: async () => null,+ awake: { set: () => {} },+ sleep: (ms: number) => sleep(Math.min(ms, 50)),+ log: (line: string) => void p.logs.push(line),+ readGpu: async () => null,+ idleClaimMs: 200,+ faceNodes: true,+ ...(o.faceSettleMs !== undefined && { faceSettleMs: o.faceSettleMs }),+ selfCheck: async () => {+ const from = Date.now();+ await sleep(o.checkMs ?? 20);+ const read = o.read(p.checks.length + 1);+ p.checks.push({ from, to: Date.now(), read });+ return read;+ },+ },+ );+ running.push({ ctrl, done });+ return p;+}++async function until<T>(fn: () => T | Promise<T>, ms = 60_000, every = 50): Promise<Exclude<T, false | null | undefined | 0 | "">> {+ const end = Date.now() + ms;+ for (;;) {+ const v = await fn();+ if (v) return v as Exclude<T, false | null | undefined | 0 | "">;+ if (Date.now() > end) throw new Error(`Timed out after ${ms} ms`);+ await sleep(every);+ }+}+const ended = (id: string) => until(() => ["done", "failed", "canceled"].includes(task(id).state) && task(id), 90_000);+const comfyOf = (p: Pc) => {+ try {+ return JSON.parse(fs.readFileSync(path.join(p.workDir, "comfyui.pid"), "utf8")) as { pid: number; port: number };+ } catch {+ return null;+ }+};+const fakeStats = async (port: number) => (await realFetch(`http://127.0.0.1:${port}/__fake/stats`)).json() as Promise<{ step: number | null }>;+const starts = (p: Pc) => p.logs.filter((l) => /^Starting its own ComfyUI/.test(l)).length;+const faceRestarts = (p: Pc) => p.logs.filter((l) => /Its face check .*: starting its ComfyUI again/.test(l)).length;++describe("the face self-check in the worker's run", () => {+ it("the check after its ComfyUI starts runs before its first claim, with a job already waiting", async () => {+ const w = addWorker();+ const id = addTask();+ const p = start(w, { read: () => PASS, checkMs: 1500 });+ expect((await ended(id)).state).toBe("done");+ expect(p.checks.length).toBeGreaterThanOrEqual(1);+ expect(p.claims.length).toBeGreaterThanOrEqual(1);+ expect(p.claims[0]).toBeGreaterThanOrEqual(p.checks[0].to);+ });++ it("its ComfyUI stops under a running job: no check and no restart under that job, the job ends, and the owed check runs between jobs", async () => {+ const w = addWorker();+ const id = addTask();+ // Any check while the job is in the studio's hands would only time out (the GPU is busy with it).+ const p = start(w, { read: () => (["sending", "queued", "running", "collecting"].includes(task(id).state) ? { ok: false, height: null, why: "timeout" } : PASS), steps: 10, stepMs: 150, faceSettleMs: 500 });+ const comfy = await until(async () => {+ const c = comfyOf(p);+ return c && ((await fakeStats(c.port).catch(() => null))?.step ?? 0) >= 3 ? c : null;+ });+ const checksBefore = p.checks.length;+ process.kill(comfy.pid, "SIGKILL");+ const t = await ended(id);+ expect(t.state).toBe("done");+ expect(t.requeues).toBe(0);+ expect(starts(p)).toBe(2);+ expect(p.logs.some((l) => /Its face check after its start waits: a job is in hand/.test(l))).toBe(true);+ // No check ran while the job was in hand, so none timed out and none started its ComfyUI again.+ expect(p.checks.slice(checksBefore).every((c) => c.read.ok)).toBe(true);+ expect(faceRestarts(p)).toBe(0);+ // Between jobs, once its GPU settled: the check it owed.+ await until(() => p.checks.length > checksBefore && p.checks.at(-1)!.read.ok, 10_000);+ expect(starts(p)).toBe(2);+ });++ it("a check before a face job fails: the job goes back in line (not failed), its ComfyUI starts again with no job in hand, then the job runs", async () => {+ const w = addWorker();+ // 1: after its start (passes). 2: before the face job (reads a wrong face). 3, 4: between jobs, then after the restart.+ const p = start(w, { read: (n) => (n === 2 ? { ok: false, height: 90, why: "height" } : n === 3 ? { ok: false, height: 90, why: "height" } : PASS) });+ await until(() => p.checks.length >= 1 && p.claims.length >= 1);+ const id = addTask({ face: true });+ const t = await ended(id);+ expect(t.state).toBe("done");+ expect(t.requeues).toBe(0);+ expect(p.reports.some((r) => r.event === "give-back" && r.why === "self-check")).toBe(true);+ expect(p.reports.some((r) => r.event === "failed")).toBe(false);+ expect(p.logs.some((l) => /Its face check before a face job read 90 px \(height\): this job goes back in line, and its ComfyUI starts again once no job is in hand/.test(l))).toBe(true);+ // Its ComfyUI started again once, between jobs (never under the job), and the check passed after it.+ expect(p.logs.some((l) => /Its face check between jobs read 90 px \(height\): starting its ComfyUI again/.test(l))).toBe(true);+ expect(faceRestarts(p)).toBe(1);+ expect(p.logs.some((l) => /Its face check passed after the restart/.test(l))).toBe(true);+ expect(p.logs.some((l) => /face jobs go back in line for 5 minutes/.test(l))).toBe(false);+ });++ it("a check that times out just after a job is 'not checked yet': no restart and no hold; checked again between jobs", async () => {+ const w = addWorker();+ let firstFaceCheck = 0;+ const p = start(w, {+ // Before the first face job (just after the other job): a timeout. Every other check passes.+ read: (n) => {+ if (firstFaceCheck === 0 && p.logs.some((l) => /Job .* done/i.test(l))) firstFaceCheck = n;+ return n === firstFaceCheck ? { ok: false, height: null, why: "timeout" } : PASS;+ },+ faceSettleMs: 3000,+ });+ await until(() => p.checks.length >= 1 && p.claims.length >= 1);+ const plain = addTask();+ expect((await ended(plain)).state).toBe("done");+ const face = addTask({ face: true });+ const t = await ended(face);+ expect(t.state).toBe("done");+ expect(t.requeues).toBe(0);+ expect(p.logs.some((l) => /Its face check before a face job timed out while its GPU was busy: not checked yet/.test(l))).toBe(true);+ expect(faceRestarts(p)).toBe(0);+ expect(starts(p)).toBe(1);+ expect(p.logs.some((l) => /face jobs go back in line for 5 minutes/.test(l))).toBe(false);+ });+});