diff --git a/components/project-creation-modal.tsx b/components/project-creation-modal.tsx index a564579..44a7d83 100644 --- a/components/project-creation-modal.tsx +++ b/components/project-creation-modal.tsx @@ -329,9 +329,11 @@ export function ProjectCreationModal({ {createdTheiaUrl ? ( ) : ( - + )} - Dedicated IDE workspace{createdTheiaUrl ? ` at ${createdTheiaUrl.replace('https://', '')}` : ' — provisioning failed'} + Dedicated IDE workspace{createdTheiaUrl + ? ` at ${createdTheiaUrl.replace('https://', '')}` + : ' — provisioning in background (ready in ~30s)'} diff --git a/lib/cloud-run-workspace.ts b/lib/cloud-run-workspace.ts index 71f622d..54e1de1 100644 --- a/lib/cloud-run-workspace.ts +++ b/lib/cloud-run-workspace.ts @@ -112,6 +112,16 @@ export async function provisionTheiaWorkspace( if (!createRes.ok) { const body = await createRes.text(); + + // 409 = service already exists — fetch its URL instead of failing + if (createRes.status === 409) { + console.log(`[workspace] Cloud Run service already exists: ${serviceName} — fetching existing URL`); + const serviceUrl = await waitForServiceUrl(serviceName, token); + await allowUnauthenticated(serviceName, token); + console.log(`[workspace] Linked to existing service: ${serviceName} → ${serviceUrl}`); + return { serviceUrl, serviceName }; + } + throw new Error(`Cloud Run create service failed (${createRes.status}): ${body}`); }