pg_net: Idiomatic synchronous execution / waiting for response? #28771
Replies: 1 comment
-
For now I'd recommend just using pgsql-http as it offers sync requests.
Although even with
That being said, I see how that's inconvenient. I've opened: supabase/pg_net#154. |
Beta Was this translation helpful? Give feedback.
-
I am using a wrapper function around pg_net to call an edge function when rows are inserted. For my previous use cases, the response from the edge function has been irrelevant; but for a new use case I want to consider the insert transaction valid only when the edge function call has finished or when the response contains a specific status code.
I already learned the following:
async
parameter forhttp_get
was removed for technical reasons. (source)net.http_collect_response()
can be used to determine the execution state and status code (source)net._http_response
directly is mentioned as alternative (source), but my corresponding code (see below) runs into a timeout becausenet._http_response
is never updated and the HTTP call to the edge function is not executed. I assume that the query would need to be executed in a separate transaction.pg_net
rather than adding a second HTTP module.Looking forward to hear your ideas and suggestions!
Example code: Querying net._http_response
Omitted: code from my original wrapper function. I added the code below just above the final
RETURN NEW
:Beta Was this translation helpful? Give feedback.
All reactions