Supabase project creation: read confirmation_id, and say plainly when the free project limit is reached

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minimus7andClaude Opus 5.5 committed 2026-11-09 11:57:01 -06:00
1 parent 5893af22c1
commit f674cc7baf
2 files changed
+12 -2

No files matched your search

+1 -1
View File
@@ -27,6 +27,6 @@ export async function POST(request: Request) {
return NextResponse.json(await fillFrom(id));
} catch (e) {
console.error("[broke] supabase project:", e instanceof Error ? e.message : e);
return NextResponse.json({ error: e instanceof Error && /cost money|organization/.test(e.message) ? e.message : "Supabase didn't answer. Try again in a moment." }, { status: 502 });
return NextResponse.json({ error: e instanceof Error && /cost money|organization|free projects/.test(e.message) ? e.message : "Supabase didn't answer. Try again in a moment." }, { status: 502 });
}
}
+11 -1
View File
@@ -175,6 +175,16 @@ async function callFit(client: Client, name: string, pool: Record<string, unknow
/** Makes a free project called "broke" in the first organization, and waits until it's ready (a minute or two). */
export async function createProject(region = "us-east-1") {
try {
return await makeProject(region);
} catch (e) {
// Supabase allows each person 2 active free projects, counted across all their organizations.
if (/maximum limits?|project limit/i.test(e instanceof Error ? e.message : "")) throw new Error("Your Supabase account already has 2 free projects, Supabase's limit. Pause or delete one at supabase.com, then try again. Or connect again and pick the organization that has a project to use.");
throw e;
}
}
async function makeProject(region: string) {
const s = load();
const client = await connectClient(s);
try {
@@ -193,7 +203,7 @@ export async function createProject(region = "us-east-1") {
} catch (e) {
if (!/confirm/i.test(e instanceof Error ? e.message : "")) throw e;
const confirm = await callFit(client, "confirm_cost", { ...pool, amount });
pool.confirm_cost_id = (() => { try { const c = JSON.parse(confirm) as { confirm_cost_id?: string; id?: string }; return c.confirm_cost_id ?? c.id; } catch { return confirm.match(/[A-Za-z0-9_-]{16,}/)?.[0] ?? confirm.trim(); } })();
pool.confirm_cost_id = (() => { try { const c = JSON.parse(confirm) as { confirmation_id?: string; confirm_cost_id?: string; id?: string }; return c.confirmation_id ?? c.confirm_cost_id ?? c.id; } catch { return confirm.match(/[A-Za-z0-9_-]{16,}/)?.[0] ?? confirm.trim(); } })();
made = one(await callFit(client, "create_project", pool));
}
for (let i = 0; i < 60; i++) {