fix: handle Cloud Run 409 by linking to existing service; show provisioning spinner not failure

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-19 17:31:01 -08:00
parent f4ab70822c
commit b42edbe681
2 changed files with 14 additions and 2 deletions

View File

@@ -329,9 +329,11 @@ export function ProjectCreationModal({
{createdTheiaUrl ? ( {createdTheiaUrl ? (
<CheckCircle2 className="h-3.5 w-3.5 text-green-500 shrink-0" /> <CheckCircle2 className="h-3.5 w-3.5 text-green-500 shrink-0" />
) : ( ) : (
<XCircle className="h-3.5 w-3.5 text-yellow-500 shrink-0" /> <Loader2 className="h-3.5 w-3.5 text-blue-400 shrink-0 animate-spin" />
)} )}
Dedicated IDE workspace{createdTheiaUrl ? ` at ${createdTheiaUrl.replace('https://', '')}` : ' — provisioning failed'} Dedicated IDE workspace{createdTheiaUrl
? ` at ${createdTheiaUrl.replace('https://', '')}`
: ' — provisioning in background (ready in ~30s)'}
</li> </li>
</ul> </ul>
</div> </div>

View File

@@ -112,6 +112,16 @@ export async function provisionTheiaWorkspace(
if (!createRes.ok) { if (!createRes.ok) {
const body = await createRes.text(); 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}`); throw new Error(`Cloud Run create service failed (${createRes.status}): ${body}`);
} }