Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

Hosted runs: plain words when the billing or moderation service doesn't answer

Adarshd833b452eabe
diff --git a/docs/billing-hook.md b/docs/billing-hook.md
index ec4e0108..6536d6a0 100644
--- a/docs/billing-hook.md
+++ b/docs/billing-hook.md
@@ -182,6 +182,6 @@ report from what is stored. A run whose rows couldn't be made after its reserve
|---|---|
| No `FUOBE_BILLING_URL` | No call. Runs on this install's GPUs are closed, or free and allowed with `FUOBE_HOSTED_FREE=1`. |
| Set, and it answers | As above. |
-| Set, and no answer in time | Runs on this install's GPUs are refused (503, "Runs are paused for a moment. Try again soon."). Run shows "Price unavailable". Runs on the account's own GPU or key go on. Reports wait in the outbox and are sent when it is back. Runs that already have a hold keep running. |
+| Set, and no answer in time | Runs on this install's GPUs are refused (503, "Try again in a moment."). Before Run, the price slot says "Ready in a moment" and Run is off; the price check asks again by itself, and Run comes back on with its answer. Runs on the account's own GPU or key go on. Reports wait in the outbox and are sent when it is back. Runs that already have a hold keep running. |
The service's address and its errors are written to the server's log only. A browser never sees them.
diff --git a/docs/moderation-hook.md b/docs/moderation-hook.md
index b91a21f8..67744010 100644
--- a/docs/moderation-hook.md
+++ b/docs/moderation-hook.md
@@ -27,8 +27,9 @@ The owner's own runs are never sent to the service.
## The run check
The check comes first, before a billing hold. `{ allowed: false }` stops the run: nothing is made, nothing is charged,
-and the person sees the service's `text` (403). No answer in time: the run is refused with "Checks are paused for a
-moment" (503).
+and the person sees the service's `text` (403). No answer in time: the run is refused (503). On this install's GPUs it
+says "Try again in a moment.", as when the billing service doesn't answer. On the account's own GPU or key it says
+"Checks are paused for a moment. Try again soon."
## The output check, and when a service may skip it
diff --git a/src/server/billing.ts b/src/server/billing.ts
index 7654ff3c..d68a3cd8 100644
--- a/src/server/billing.ts
+++ b/src/server/billing.ts
@@ -165,8 +165,12 @@ export interface RefundReport {
device: string | null;
}
-/** What a person sees when the billing service doesn't answer: never its address or its error. */
-export const BILLING_PAUSED = "Runs are paused for a moment. Try again soon.";
+/**
+ * What a person sees when the billing service doesn't answer: never its address, its error or a word about the service.
+ * `quote`: the price slot before Run (the price check asks again by itself, and Run comes back on with its answer);
+ * `run`: a run pressed then, which didn't start.
+ */
+export const BILLING_WAIT = { quote: "Ready in a moment", run: "Try again in a moment." } as const;
/** Timeouts per call (ms). */
export const BILLING_TIMEOUTS = { policy: 1000, quote: 1000, reserve: 2000, balance: 1000, report: 5000, event: 5000 };
@@ -273,7 +277,7 @@ export async function quote(account: AccountFacts | null, run: RunFacts, queue:
return await call<Quote>("POST", "/v1/quote", { account, run, queue }, BILLING_TIMEOUTS.quote);
} catch (e) {
logDown("quote", e);
- return { allowed: false, amount: 0, priceVersion: "", text: BILLING_PAUSED, code: "paused" };
+ return { allowed: false, amount: 0, priceVersion: "", text: BILLING_WAIT.quote, code: "paused" };
}
}
@@ -292,7 +296,7 @@ export async function reserve(input: { requestId: string; account: AccountFacts;
logDown(`reserve (try ${attempt + 1})`, e);
}
}
- return { ok: false, code: "paused", text: BILLING_PAUSED };
+ return { ok: false, code: "paused", text: BILLING_WAIT.run };
}
/** The HTTP status and header for a billing refusal (the generations route; docs/billing-hook.md). */
diff --git a/src/server/hosted-run.ts b/src/server/hosted-run.ts
index dafa6c10..11eeef19 100644
--- a/src/server/hosted-run.ts
+++ b/src/server/hosted-run.ts
@@ -8,7 +8,7 @@ import { accountGpu, type Account } from "./auth";
import {
accountFacts,
BILLING_HEADER,
- BILLING_PAUSED,
+ BILLING_WAIT,
billingConfigured,
cachedPolicy,
forgetBalance,
@@ -271,7 +271,7 @@ export async function decidePlace(account: Account, asked: GenerationRequest, wi
}
}
if (p === undefined) p = await billingPolicy(account.id);
- if (!p) return ownFallback ? OWN : { kind: "refuse", refusal: billingRefusal("paused", BILLING_PAUSED) };
+ if (!p) return ownFallback ? OWN : { kind: "refuse", refusal: billingRefusal("paused", BILLING_WAIT.run) };
// Closed to this account: its own GPU (or today's "Connect your GPU"); asked for by name, said so.
if (!p.hosted) return wish === "pool" ? notOffered(HOSTED_WORDS.notHosted) : OWN;
// Planned, checked and priced for the outputs it would make there (the policy's cap per run).
@@ -353,7 +353,9 @@ export async function moderateRun(
});
if (a.allowed) return { ok: true, checkOutputs: a.checkOutputs !== false };
const status = a.code === "paused" ? 503 : 403;
- return { ok: false, refusal: { status, body: { error: a.text, code: a.code }, headers: {} } };
+ // No answer from the service, on this install's GPUs: the same plain words as when the billing service doesn't answer.
+ const error = a.code === "paused" && place === "pool" ? BILLING_WAIT.run : a.text;
+ return { ok: false, refusal: { status, body: { error, code: a.code }, headers: {} } };
}
/**
diff --git a/tests/billing-hook.test.ts b/tests/billing-hook.test.ts
index db240cfb..c81b22a8 100644
--- a/tests/billing-hook.test.ts
+++ b/tests/billing-hook.test.ts
@@ -223,15 +223,16 @@ describe("the billing hook with a service", () => {
}
});
- it("service down: runs on this install's GPUs are paused with plain words, and a run on the account's own GPU still goes", async () => {
+ it("service down: runs on this install's GPUs are refused in plain words with no word of a pause, and a run on the account's own GPU still goes", async () => {
fake.down = "error";
const r = await post({ ...run(), shown: { amount: 7, priceVersion: "v7" } });
expect(r.status).toBe(503);
const body = (await r.json()) as { error: string };
- expect(body.error).toBe(billing.BILLING_PAUSED);
+ expect(body.error).toBe(billing.BILLING_WAIT.run);
+ expect(body.error).not.toMatch(/paus/i);
expect(JSON.stringify(body)).not.toContain(String(fake.port));
const p = await post(run(), cookie, "?preview=1");
- expect(((await p.json()) as { quote: { code: string } }).quote.code).toBe("paused");
+ expect(((await p.json()) as { quote: unknown }).quote).toMatchObject({ allowed: false, code: "paused", text: billing.BILLING_WAIT.quote });
// Its own GPU online: its own GPU is the place, and the billing service is never asked.
fake.calls.length = 0;
const own = await post(run(), gpuCookie);
diff --git a/tests/hosted-price-check.test.ts b/tests/hosted-price-check.test.ts
index 14aa8200..943a5513 100644
--- a/tests/hosted-price-check.test.ts
+++ b/tests/hosted-price-check.test.ts
@@ -136,11 +136,13 @@ describe("the price check with hosted runs on", () => {
expect(r.body.quote).toMatchObject({ allowed: false, code: "busy", text: "Busy right now. Try again in about 10 min." });
});
- it("the service not answering: refused as paused, in plain words", async () => {
+ it("the service not answering: refused before Run in plain words, with no word of a pause", async () => {
useService();
fake.down = "error";
const r = await check(fox);
- expect(r.body.quote).toMatchObject({ allowed: false, code: "paused", text: billing.BILLING_PAUSED });
+ expect(r.body.quote).toMatchObject({ allowed: false, code: "paused", text: billing.BILLING_WAIT.quote });
+ const { text, sub } = r.body.quote as { text: string; sub?: string };
+ expect(`${text} ${sub ?? ""}`).not.toMatch(/paus/i);
});
it("the policy's limits on runs at once and in line are said before Run, with the run's own words", async () => {
diff --git a/tests/moderation-hook.test.ts b/tests/moderation-hook.test.ts
index 278a004a..3652a8db 100644
--- a/tests/moderation-hook.test.ts
+++ b/tests/moderation-hook.test.ts
@@ -122,10 +122,24 @@ describe("the run check", () => {
expect(sent.body).toMatchObject({ prompt: "a quiet harbour", account: { id: a }, consent: null });
});
- it("no answer: the run is refused as paused", async () => {
+ it("no answer: a run on this install's GPUs is refused in plain words, with no word of a pause", async () => {
mod.down = true;
+ const before = (db().prepare("SELECT COUNT(*) AS n FROM generations").get() as { n: number }).n;
const r = await post(run);
expect(r.status).toBe(503);
+ const body = (await r.json()) as { error: string };
+ expect(body.error).toBe(billing.BILLING_WAIT.run);
+ expect(body.error).not.toMatch(/paus|check/i);
+ expect((db().prepare("SELECT COUNT(*) AS n FROM generations").get() as { n: number }).n).toBe(before);
+ });
+
+ it("no answer: a run on the account's own GPU keeps today's words", async () => {
+ mod.down = true;
+ const { moderateRun } = await import("@/server/hosted-run");
+ const { CHECKS_PAUSED } = await import("@/server/moderation");
+ const account = auth.checkAccount("[email protected]", "long enough")!;
+ const own = await moderateRun(account, { ...run, feature: "video" }, null, "own", { kind: "video", place: "own-gpu" });
+ expect(own).toMatchObject({ ok: false, refusal: { status: 503, body: { error: CHECKS_PAUSED, code: "paused" } } });
});
});