A maximum timeout of 5000ms when calling an edge function through the pg_cron extension?
#37574
Replies: 4 comments 3 replies
|
Cron has no timeout. |
|
Currently, an easy workaround is just using an obfuscated SQL invocation using |
|
Just a small note for anyone copying this pattern: the select true as dummy_value trick works because it makes the query look like a general SQL statement rather than a direct edge function invocation, which bypasses the UI's validation logic. A bit silly but it does the job. One thing worth considering if your edge function genuinely needs 50 seconds to complete, pg_net is fire-and-forget, so you won't get the response back in your cron job regardless of the timeout. The timeout just controls how long pg_net waits before giving up on establishing the connection and sending the request. If you need to track whether the function actually succeeded, you'll want the edge function to write its status back to a table when it finishes. Also, for long-running migrations like what you're doing with HubSpot, you might hit Edge Function's own execution time limits (default 60s on Pro, can be increased). If the migration involves processing lots of records, batching with multiple cron invocations or using Supabase's background tasks might be more reliable than one long-running function. |
|
Do you know if using a background task https://supabase.com/docs/guides/functions/background-tasks could work when calling from a cron job? |

Cron has no timeout.
Pg_net has a timeout option but I don't think it is limited to 5000 as webhooks UI allows 10000.
So must be a Supabase Cron UI decision. Not sure why.
You could use SQL to create the job I assume.