Increase Supabase CRON Timeout
Hi,
I'm seeing Supabase CRON Runs have error:
I'm trying to run a LRO HTTP POST on a schedule that may take up to 60 minutes.
Do I need to somehow modify pg_cron or my function?
pg_cron:
CRON schedule (0 10 * * *):
CRON function:
I'm seeing Supabase CRON Runs have error:
ERROR: Operation timed out after 5002 milliseconds with 0 bytes received
CONTEXT: PL/pgSQL function run_browser_gym(text) line 87 at assignmentERROR: Operation timed out after 5002 milliseconds with 0 bytes received
CONTEXT: PL/pgSQL function run_browser_gym(text) line 87 at assignmentI'm trying to run a LRO HTTP POST on a schedule that may take up to 60 minutes.
Do I need to somehow modify pg_cron or my function?
pg_cron:
create extension if not exists "pg_cron" with schema "pg_catalog";create extension if not exists "pg_cron" with schema "pg_catalog";CRON schedule (0 10 * * *):
SELECT run_browser_gym('gusto');SELECT run_browser_gym('gusto');CRON function:
-- Add TOTP secret to toast provider in gym endpoint
-- This migration adds the totpSecret field to the toast provider configuration
CREATE OR REPLACE FUNCTION run_browser_gym(p_source_provider text)
RETURNS http_response
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
DECLARE
req http_request;
resp http_response;
v_payload jsonb;
v_login_input jsonb;
BEGIN
v_payload := jsonb_build_object(
'sourceProvider', p_source_provider,
'loginInput', v_login_input
);
req := (
'POST',
worker_url() || '/test/gym',
array[
('Content-Type', 'application/json'),
('Authorization', 'Bearer ' || create_stytch_m2m_jwt())
]::http_header[],
'application/json',
v_payload::text
)::http_request;
resp := http(req);
IF resp.status NOT BETWEEN 200 AND 299 THEN
RAISE EXCEPTION 'HTTP request failed with status %: %', resp.status, resp.content;
END IF;
RETURN resp;
END;
$$;-- Add TOTP secret to toast provider in gym endpoint
-- This migration adds the totpSecret field to the toast provider configuration
CREATE OR REPLACE FUNCTION run_browser_gym(p_source_provider text)
RETURNS http_response
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
DECLARE
req http_request;
resp http_response;
v_payload jsonb;
v_login_input jsonb;
BEGIN
v_payload := jsonb_build_object(
'sourceProvider', p_source_provider,
'loginInput', v_login_input
);
req := (
'POST',
worker_url() || '/test/gym',
array[
('Content-Type', 'application/json'),
('Authorization', 'Bearer ' || create_stytch_m2m_jwt())
]::http_header[],
'application/json',
v_payload::text
)::http_request;
resp := http(req);
IF resp.status NOT BETWEEN 200 AND 299 THEN
RAISE EXCEPTION 'HTTP request failed with status %: %', resp.status, resp.content;
END IF;
RETURN resp;
END;
$$;