getaddrinfo ENOTFOUND supabase_db_XXX
riderx opened this issue · 5 comments
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Since last update to pg image 15.8.1.034 i cannot connect from the edge worker to the postgres db with PbClient.
It still work with the Supabase SDK.
To Reproduce
On empty project add new function with supabase functions new test_pg
as doc here: https://supabase.com/docs/guides/functions/connect-to-postgres
import postgres from 'postgres'
// Setup type definitions for built-in Supabase Runtime APIs
import 'jsr:@supabase/functions-js/edge-runtime.d.ts'
const connectionString = Deno.env.get('SUPABASE_DB_URL')!
console.log('Hello from Functions!')
Deno.serve(async (_req) => {
// Disable prefetch as it is not supported for "Transaction" pool mode
const client = postgres(connectionString, { prepare: false })
const res = await client`select 1`.catch((e) => {
console.log('error', e)
})
console.log('res', res)
return Response.json(res)
})edit Deno.json
{
"imports": {
"postgres": "npm:postgres@3.4.5"
}
}then do
curl -X "POST" "http://127.0.0.1:54321/functions/v1/test_pg" \
-H 'Accept-Encoding: gzip, zlib, deflate, zstd, br'Inspect the log of the docker egde container and the error getaddrinfo should be visible.
Expected behavior
Connection between machines should work properly locally.
System information
- OS: MacOs
Docker Desktop 4.38.0 (181591)
CLI: v2.12.1
Gotrue: v2.169.0
Postgres: 15.8.1.034
Res: v12.2.3
Storage: v1.17.1
Doing in the edge machine this:
apt-get update -y
apt-get install -y iputils-ping
# ping supabase_db_capgo-app:54322
ping: supabase_db_capgo-app:54322: Name or service not knownFail as well so i think something change in the local networking settings
Reproduction here: https://github.com/riderx/supabase_edge_issue
run
bun test:pgThis is likely an issue with the npm:postgres library itself, I'm guessing a setting needs to be set somewhere. I've tried your code and it does give the same error on this side but if I use deno-postgres I don't face any issues.
import { Client } from "https://deno.land/x/postgres/mod.ts"
// Setup type definitions for built-in Supabase Runtime APIs
import "jsr:@supabase/functions-js/edge-runtime.d.ts"
console.log("Hello from Functions!")
const connectionString = Deno.env.get('SUPABASE_DB_URL')!
Deno.serve(async (req) => {
// Disable prefetch as it is not supported for "Transaction" pool mode
const client = new Client(connectionString)
await client.connect()
const res = await client.queryArray("SELECT 1")
console.log('result', res)
return Response.json(res)
})I close then thanks
I recommend posting issues like this to https://github.com/supabase/cli/issues which covers issues with running the supabase command, and the images that are associated with that. Recommend re-posting there.
