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
Queue settings: a stored setting this version doesn't know leaves the others in effect
Adarsh44273287b4b0
diff --git a/src/server/queue-settings.ts b/src/server/queue-settings.tsindex 67fb5c33..7d322bbf 100644--- a/src/server/queue-settings.ts+++ b/src/server/queue-settings.ts@@ -47,11 +47,19 @@ declare global {const copy = (s: QueueSettings): QueueSettings => ({ ...s, runCeilingS: { default: s.runCeilingS.default, lanes: { ...s.runCeilingS.lanes } } });-/** A stored value read leniently: anything that isn't valid is the default (a bad row never stops a run). */+/** The settings this version knows. */+const QUEUE_KEYS = ["runCeilingS", "ownerWaitLimitS", "fairShare", "pickAllowanceMs", "pausedBudgetS"];++/**+ * A stored value read leniently: anything that isn't valid is the default (a bad row never stops a run). A setting+ * this version doesn't know (one an earlier or later version stored) is left out, so the others still count.+ */function fromStored(raw: string | null): QueueSettings {if (!raw) return copy(QUEUE_DEFAULTS);try {- const r = checkQueuePatch(JSON.parse(raw) as unknown, QUEUE_DEFAULTS);+ const v = JSON.parse(raw) as unknown;+ const known = v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).filter(([k]) => QUEUE_KEYS.includes(k))) : v;+ const r = checkQueuePatch(known, QUEUE_DEFAULTS);return "error" in r ? copy(QUEUE_DEFAULTS) : r.settings;} catch {return copy(QUEUE_DEFAULTS);@@ -79,8 +87,7 @@ const inRange = (v: unknown, b: { min: number; max: number }): v is number => whexport function checkQueuePatch(body: unknown, base: QueueSettings = queueSettings()): { settings: QueueSettings } | { error: string } {if (!body || typeof body !== "object" || Array.isArray(body)) return { error: "Send the settings as an object" };const b = body as Record<string, unknown>;- const known = ["runCeilingS", "ownerWaitLimitS", "fairShare", "pickAllowanceMs", "pausedBudgetS"];- const unknown = Object.keys(b).filter((k) => !known.includes(k));+ const unknown = Object.keys(b).filter((k) => !QUEUE_KEYS.includes(k));if (unknown.length) return { error: `Unknown setting: ${unknown[0]}` };const out = copy(base);const { min, max } = QUEUE_BOUNDS.ceilingS;diff --git a/tests/pool-line-order.test.ts b/tests/pool-line-order.test.tsindex cd3e14c6..a6f0b0a2 100644--- a/tests/pool-line-order.test.ts+++ b/tests/pool-line-order.test.ts@@ -779,6 +779,15 @@ describe("GET and PATCH /api/admin/queue/settings", () => {expect(qs.queueSettings()).toEqual(qs.QUEUE_DEFAULTS);});+ it("a stored value with a setting this version doesn't know keeps the settings it knows", () => {+ const stored = { runCeilingS: { default: 2700, lanes: { small: 7200 } }, ownerWaitLimitS: null, fairShare: false, pickAllowanceMs: 0, pausedBudgetS: 3600, retiredSetting: 5 };+ db().prepare("INSERT INTO settings (key, value) VALUES ('queue.settings', ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(JSON.stringify(stored));+ globalThis.__fuobeQueueSettings = undefined;+ const known: Record<string, unknown> = { ...stored };+ delete known.retiredSetting;+ expect(qs.queueSettings()).toEqual(known);+ });+it("an admin token reads them with queue:read and changes them with queue:write", async () => {const make = (scopes: import("@/server/admin-tokens").Scope[]) => admin.createAdminToken({ name: `t-${Math.random()}`, scopes });const reader = make(["queue:read"]);