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:
11 Replies
The issue is not pg_cron.
It is with the http extension. It has a 5 second timeout.
Thank you. Great incite.
https://pgxn.org/dist/http/
From my understanding I can update the http extension's timeout with:
ALTER SYSTEM SET http.timeout_msec = 3600000; -- 60 minutes in milliseconds
I'll investigate more.PGXN: PostgreSQL Extension Network
http: HTTP client for PostgreSQL / PostgreSQL Extension Network
HTTP allows you to get the content of a web page in a SQL function call.
https://github.com/pramsey/pgsql-http?tab=readme-ov-file#keep-alive--timeouts I don't think anyone has ever figured out how to change it.
What makes you believe that ^
By default a 5 second timeout is set for the completion of a request. If a different timeout is desired the following GUC variable can be used to set it in milliseconds:
https://github.com/pramsey/pgsql-http?tab=readme-ov-file#keep-alive--timeouts
I don't believe you can set that in Supabase.
Several users have tried in the past. Maybe you will be successful.
Also not great to have it lock up the transaction for that long.
pg_net is async, but you have to come back and get the results later from a result table.
Maybe an edge function should be called and update the DB when it gets the result back.
In our case, we don't really care about the HTTP response. Worst case I believe we can ignore the timeout.
5 seconds without configurability seems like it should be a warning on this doc page:
https://supabase.com/docs/guides/database/extensions/http
If you don't need the response use pg_net.
ahh – thank you. Seems like better fit
GitHub
Adjusting timeout for http-extension · supabase · Discussion #13760
Is there a way to adjust the timeout for the http-extension? I've tried using the commands they suggest on their GitHub(https://github.com/pramsey/pgsql-http, I've tried both http_set_curlo...
Been a long time since I played with it though. But pg_net is better for what you want.
That will likely fix this error. Will be testing it. Will raise a separate issue if something arises. Thanks Austin.