supabase / pg_net

A PostgreSQL extension that enables asynchronous (non-blocking) HTTP/HTTPS requests with SQL
https://supabase.github.io/pg_net
Apache License 2.0
213 stars 16 forks source link

pg_net not working in self-hosted supabase #85

Closed Jaarson closed 1 year ago

Jaarson commented 1 year ago

Bug report

pg_net not working in self-hosted supabase

Describe the bug

Running this query does nothing, no errors, http_request_queue and _http_response tables are empty. Although, it returns incrementing number of request_id on each run.

select net.http_get('https://news.ycombinator.com') as request_id;

Using pg_net 0.6

steve-chavez commented 1 year ago

Using pg_net 0.6

There are newer versions now https://github.com/supabase/pg_net/releases/tag/v0.7.

pg_net not working in self-hosted supabase

How do you do self-hosted, through the CLI?

Jaarson commented 1 year ago

Thanks, how do I upgrade from 0.6 to 0.7? I use self-hosted locally for dev only with docker compose up, not using CLI.

soedirgo commented 1 year ago

Assuming your DB data is in a container volume (make sure to backup before trying this!), you can try updating the DB image version in the Compose file and restarting the container.

Then newer pg_net versions should be available in your DB and you can upgrade with alter extension pg_net update.

grschafer commented 1 year ago

Perhaps this belongs in a new issue, though I would likely give it a similar title to this issue. I'm running pg_net 0.7.1 locally using the supabase CLI (postgres image version is 15.1.0.42-rc2) and all requests that I make are failing as follows:

postgres@supabase_db_project/postgres=# select
    net.http_post(
        url:='https://httpbin.org/post',
        body:='{"hello": "world"}'::jsonb
    ) as request_id;
 request_id 
------------
          4
(1 row)

postgres@supabase_db_project/postgres=# select net._http_collect_response(4, async:=false);
 _http_collect_response 
------------------------
 (SUCCESS,ok,"(,,)")
(1 row)

postgres@supabase_db_project/postgres=# table net._http_response;
 id | status_code | content_type | headers | content | timed_out |                     error_msg                     |            created            
----+-------------+--------------+---------+---------+-----------+---------------------------------------------------+-------------------------------
  1 |           ¤ | ¤            | ¤       | ¤       | ¤         | SSL peer certificate or SSH remote key was not OK | 2023-03-01 23:41:26.200221+00
  2 |           ¤ | ¤            | ¤       | ¤       | ¤         | SSL peer certificate or SSH remote key was not OK | 2023-03-01 23:41:46.392894+00
  3 |           ¤ | ¤            | ¤       | ¤       | ¤         | SSL peer certificate or SSH remote key was not OK | 2023-03-01 23:42:24.61332+00
  4 |           ¤ | ¤            | ¤       | ¤       | ¤         | SSL peer certificate or SSH remote key was not OK | 2023-03-02 00:12:53.520705+00
(4 rows)

(I have psql configured to show ¤ for nulls, via \pset null '¤'.)

I've confirmed on a new supabase.com project (with pg_net 0.7.1) that making these same queries works as I would expect, so this issue is something to do with the local/docker environment. I'm not sure how to debug further though -- there's nothing in the postgres logs.

EDIT: Tried again after upgrading supabase CLI 1.38.6 -> 1.41.1 (now postgres docker image label is 15.1.0.52) and the issue persists.

magick93 commented 1 year ago

Has anyone found a solution to this?

This has totally killed our ability to move forward as we are reliant on this core functionality working reliably. We, like I imagine many do, develop locally then deploy to the cloud hosted supabase. We are blocked due to this bug.

soedirgo commented 1 year ago

Going to redirect the SSL errors discussion to https://github.com/supabase/postgres/issues/573, since it looks to be a different issue.

soedirgo commented 1 year ago

Also closing this issue since the original issue should be fixed with an upgrade. Feel free to comment here otherwise and we'll reopen the issue.