The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(studio): default cron HTTP timeout when timeout_milliseconds is omitted (#51385)
Yuvraj Singhd1205a05e98b
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.ts b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.tsindex 478349b8fa1..d563d799b29 100644--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.ts+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.ts@@ -133,6 +133,24 @@ describe('parseCronJobCommand', () => {})})+ it('should fall back to the pg_net default timeout when timeout_milliseconds is missing', () => {+ const command = `select net.http_post( url:='https://random_project_ref.supabase.co/functions/v1/_', headers:=jsonb_build_object('Authorization', 'Bearer something'), body:='' );`+ expect(parseCronJobCommand(command, 'random_project_ref')).toMatchObject({+ type: 'edge_function',+ timeoutMs: 5000,+ })+ })++ it('should fall back to the pg_net default timeout for http requests without timeout_milliseconds', () => {+ const command = `select net.http_get( url:='https://example.com/api' );`+ expect(parseCronJobCommand(command, 'random_project_ref')).toMatchObject({+ type: 'http_request',+ method: 'GET',+ endpoint: 'https://example.com/api',+ timeoutMs: 5000,+ })+ })+it('should return a edge function config when the body is missing', () => {const command = `select net.http_post( url:='https://random_project_ref.supabase.co/functions/v1/_', headers:=jsonb_build_object('Authorization', 'Bearer something'), timeout_milliseconds:=5000 );`expect(parseCronJobCommand(command, 'random_project_ref')).toStrictEqual({diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsxindex cc28f6118a5..7a6cd3a55a0 100644--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsx+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsx@@ -122,6 +122,9 @@ select);`}+// Default of pg_net's `timeout_milliseconds` argument, used when a command omits it+const PG_NET_DEFAULT_TIMEOUT_MS = 5000+const DEFAULT_CRONJOB_COMMAND = {type: 'sql_snippet',snippet: '',@@ -150,7 +153,7 @@ export const parseCronJobCommand = (const body = unescapeSqlLiteral(bodyMatch?.[2], Boolean(bodyMatch?.[1]))const timeoutMatch = command.match(/timeout_milliseconds:=(\d+)/i)- const timeout = timeoutMatch?.[1] || ''+ const timeoutMs = timeoutMatch ? Number(timeoutMatch[1]) : PG_NET_DEFAULT_TIMEOUT_MSlet headersObjs: { name: string; value: string }[] = []if (/headers:=jsonb_build_object\s*\(/i.test(command)) {@@ -198,7 +201,7 @@ export const parseCronJobCommand = (edgeFunctionName: url,httpHeaders: headersObjs,httpBody: body,- timeoutMs: Number(timeout ?? 1000),+ timeoutMs,snippet: originalCommand,}}@@ -210,7 +213,7 @@ export const parseCronJobCommand = (endpoint: url,httpHeaders: headersObjs,httpBody: body,- timeoutMs: Number(timeout ?? 1000),+ timeoutMs,snippet: originalCommand,}}