Give the deposit check's cron call a 60 s timeout so its result is kept (#36)

pg_net's default 5 s timeout is shorter than the check, so every call since at
least this morning was stored as a timeout and the function's result was
lost. The function kept running; only the record was missing.
This commit is contained in:
SatoshiQaziMuhammed authored and GitHub committed 2026-10-18 19:23:56 +04:00
1 parent c0c8ba074e
commit 2b2d7f10f9
1 file changed
+19
@@ -0,0 +1,19 @@
-- The deposit check takes longer than pg_net's default 5 s timeout (about
-- 15-30 s with 53 users, as TronGrid requests go one at a time), so every call
-- was recorded as a timeout and the result it returns (deposits found, errors)
-- was never stored. The function itself runs on either way; with a 60 s
-- timeout net._http_response keeps each run's result.
SELECT cron.alter_job(
job_id := (SELECT jobid FROM cron.job WHERE jobname = 'check-deposits-job'),
command := $$
SELECT net.http_post(
url := current_setting('app.settings.supabase_url') || '/functions/v1/check-deposits',
headers := jsonb_build_object(
'Authorization', 'Bearer ' || current_setting('app.settings.service_role_key'),
'Content-Type', 'application/json'
),
body := '{}'::jsonb,
timeout_milliseconds := 60000
);
$$
);