From fcebb3c5c6358ef5dd407b6e10256cfc2edee1b9 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 20:00:21 +0000 Subject: [PATCH 1/2] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/_shared/railway.ts | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/supabase/functions/_shared/railway.ts b/supabase/functions/_shared/railway.ts index 1fe73a6..414d021 100644 --- a/supabase/functions/_shared/railway.ts +++ b/supabase/functions/_shared/railway.ts @@ -132,7 +132,28 @@ export async function deployRailwayService(opts: { token: string; serviceId: string; environmentId: string; + /** Use true on the first deploy of a freshly-created service (no prior deployment exists). */ + firstDeploy?: boolean; }): Promise { + // serviceInstanceRedeploy só funciona se já existe um deployment. + // Para o primeiro deploy de um serviço recém-criado, usamos serviceInstanceDeployV2. + if (opts.firstDeploy) { + const mutation = ` + mutation ServiceInstanceDeployV2($serviceId: String!, $environmentId: String!) { + serviceInstanceDeployV2(serviceId: $serviceId, environmentId: $environmentId) + } + `; + const res = await railwayQuery( + mutation, + { serviceId: opts.serviceId, environmentId: opts.environmentId }, + opts.token, + ); + if (res.errors?.length) { + throw new Error(`serviceInstanceDeployV2 failed: ${JSON.stringify(res.errors)}`); + } + return; + } + const mutation = ` mutation ServiceInstanceRedeploy($serviceId: String!, $environmentId: String!) { serviceInstanceRedeploy(serviceId: $serviceId, environmentId: $environmentId) @@ -144,7 +165,14 @@ export async function deployRailwayService(opts: { opts.token, ); if (res.errors?.length) { - throw new Error(`serviceInstanceRedeploy failed: ${JSON.stringify(res.errors)}`); + const errStr = JSON.stringify(res.errors); + // Fallback: serviço novo sem deploy anterior — redeploy falha, tenta V2. + if (errStr.includes("no deployment") || errStr.includes("No deployments") || errStr.includes("not found")) { + console.warn(`[deployRailwayService] redeploy sem deploy anterior, fallback para serviceInstanceDeployV2`); + await deployRailwayService({ ...opts, firstDeploy: true }); + return; + } + throw new Error(`serviceInstanceRedeploy failed: ${errStr}`); } } From 3c8579fb4f8fdd0859c0eb0c664b02beddc1965c Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 20:00:31 +0000 Subject: [PATCH 2/2] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- src/routeTree.gen.ts | 9 --------- supabase/functions/provision-agent/index.ts | 1 + 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 0bb5aca..0fe84b5 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -670,12 +670,3 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) ._addFileTypes() - -import type { getRouter } from './router.tsx' -import type { createStart } from '@tanstack/react-start' -declare module '@tanstack/react-start' { - interface Register { - ssr: true - router: Awaited> - } -} diff --git a/supabase/functions/provision-agent/index.ts b/supabase/functions/provision-agent/index.ts index 1ac44c3..58b5687 100644 --- a/supabase/functions/provision-agent/index.ts +++ b/supabase/functions/provision-agent/index.ts @@ -287,6 +287,7 @@ Deno.serve(async (req) => { token: RAILWAY_API_TOKEN, serviceId: railwayServiceId, environmentId: pool.railway_environment_id, + firstDeploy: true, }); console.log(`[provision-agent] deploy disparado em Railway`); } catch (e) {