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
Runs on your own GPU or key: a queue counts as moving only once its place gets nearer the front
Adarshb3da7533e3a0
diff --git a/src/lib/guest-access.ts b/src/lib/guest-access.tsindex a0c78afc..d29165e3 100644--- a/src/lib/guest-access.ts+++ b/src/lib/guest-access.ts@@ -139,7 +139,7 @@ const LIBRARY_CHANGES: [methods: string, path: RegExp][] = [["PATCH DELETE", /^\/api\/folders\/[^/]+$/],["PATCH DELETE", /^\/api\/generations\/[^/]+$/],// (POST /api/generations/bulk goes to the route, which takes an account's likes, pins and reviews of its own runs only.)- ["POST", /^\/api\/generations\/[^/]+\/(cancel|finish)$/],+ ["POST", /^\/api\/generations\/[^/]+\/(cancel|finish|smaller)$/],["DELETE", /^\/api\/generations\/trash$/],["DELETE", /^\/api\/assets\/[^/]+$/],["POST", /^\/api\/shares$/],diff --git a/src/server/generations.ts b/src/server/generations.tsindex 03dfdce1..f79079f4 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -3153,10 +3153,11 @@ async function pollOne(r: Row): Promise<void> {let movedAt = typeof ctx.meta.queueMovedAt === "number" ? ctx.meta.queueMovedAt : run.submitted_at;const pos = res?.state === "queued" && typeof res.position === "number" ? res.position : undefined;if (ownQueue && pos !== undefined && (typeof ctx.meta.queuePos !== "number" || pos < ctx.meta.queuePos)) {- movedAt = now;+ // Its place first seen is where it starts; only a place nearer the front is a queue that moves.+ if (typeof ctx.meta.queuePos === "number") movedAt = now;db()- .prepare("UPDATE generations SET external_meta_json = json_set(CASE WHEN json_valid(external_meta_json) THEN external_meta_json ELSE '{}' END, '$.queuePos', @pos, '$.queueMovedAt', @now) WHERE id = @id AND external_id IS NOT NULL")- .run({ id: r.id, pos, now });+ .prepare("UPDATE generations SET external_meta_json = json_set(CASE WHEN json_valid(external_meta_json) THEN external_meta_json ELSE '{}' END, '$.queuePos', @pos, '$.queueMovedAt', @movedAt) WHERE id = @id AND external_id IS NOT NULL")+ .run({ id: r.id, pos, movedAt });}const queueOver = ownQueue? now - Math.max(run.submitted_at, movedAt) > queueMs * OWN_QUEUE.scale || now - run.submitted_at > OWN_QUEUE_CAP_MS * OWN_QUEUE.scalediff --git a/tests/account-keys-isolation.test.ts b/tests/account-keys-isolation.test.tsindex 3f4f35e3..851a5c23 100644--- a/tests/account-keys-isolation.test.ts+++ b/tests/account-keys-isolation.test.ts@@ -177,7 +177,8 @@ describe("an account's runs reach the provider with its own key only", () => {db().prepare("UPDATE generation_runs SET submitted_at = ? WHERE id = ?").run(Date.now() - 31 * 60_000, g.id);const done = await settle(g.id);expect(done.status).toBe("failed");- expect(done.error).toBe("This waited over 30 minutes to start. Press Retry.");+ // Its place in fal.ai's queue never moved: the provider was busy, in plain words.+ expect(done.error).toBe("fal.ai was busy for 31 minutes, so this run stopped. Press Retry in a few minutes.");const cancel = fal.log.find((r) => r.path.endsWith("/cancel"));expect(cancel?.authorization).toBe("Key acct-fal-A");expect(keysSeen(fal.log)).toEqual(["Key acct-fal-A"]);diff --git a/tests/account-keys-routes.test.ts b/tests/account-keys-routes.test.tsindex 9d8f895d..6a44ccf0 100644--- a/tests/account-keys-routes.test.ts+++ b/tests/account-keys-routes.test.ts@@ -1,6 +1,6 @@import fs from "node:fs";import path from "node:path";-import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";+import { afterAll, beforeAll, beforeEach, describe, expect, it, onTestFinished, vi } from "vitest";import { NextRequest } from "next/server";import { keysSeen, startFakeFal, startFakeReplicate, type FakeCloud } from "./helpers/fake-cloud";import { tempDir } from "./helpers/temp-dir";@@ -117,15 +117,22 @@ describe("adding a key", () => {});it("says when the provider can't be reached or answers oddly", async () => {+ // The check's own waits before it asks again, made short.+ const { KEY_CHECK } = await import("@/server/your-keys");+ KEY_CHECK.waitsMs = [10, 10];+ onTestFinished(() => {+ KEY_CHECK.waitsMs = [1_000, 3_000];+ });const odd = await put("fal", { key: "outage-key-id-1111:outage-secret-1111" });// 503, not 502: a proxy in front (Cloudflare) swaps an origin's 502 for its own page, and the words are lost.expect(odd.status).toBe(503);- expect((await odd.json()).error).toBe("fal.ai answered 503, so the key couldn't be checked. Try again in a moment.");+ // Plain words, the status in details (the check asked twice more by itself first).+ expect(await odd.json()).toEqual({ error: "fal.ai is busy right now, so we couldn't check your key. Try again in a minute.", details: "fal.ai answered 503" });globalThis.__fuobeTestFalUrl = "http://127.0.0.1:9";try {const down = await put("fal", { key: GOOD_FAL });expect(down.status).toBe(503);- expect((await down.json()).error).toBe("Couldn't reach fal.ai to check the key, so it wasn't saved. Try again in a moment.");+ expect((await down.json()).error).toBe("We couldn't reach fal.ai to check your key. Try again in a minute.");} finally {globalThis.__fuobeTestFalUrl = fal.url;}diff --git a/tests/own-keys-graceful.test.ts b/tests/own-keys-graceful.test.tsindex defd6595..7fea1566 100644--- a/tests/own-keys-graceful.test.ts+++ b/tests/own-keys-graceful.test.ts@@ -181,7 +181,7 @@ describe("an account's run on its own key waits out a busy or down provider", ()it("a voice it cloned for the run (a billed step) is used again when the run tries again, never cloned twice", async () => {const wav = tinyWav();const up = await uploadsRoute.POST(- new Request("http://localhost:3000/api/uploads", { method: "POST", headers: { cookie: cookies.A, host: "localhost:3000", "content-type": "audio/wav", "x-file-name": "sample.wav", "content-length": String(wav.length) }, body: wav }),+ new Request("http://localhost:3000/api/uploads", { method: "POST", headers: { cookie: cookies.A, host: "localhost:3000", "content-type": "audio/wav", "x-file-name": "sample.wav", "content-length": String(wav.length) }, body: new Uint8Array(wav) }),);expect(up.status, await up.clone().text()).toBe(201);const voice = ((await up.json()) as { url: string }).url;