-
-
Notifications
You must be signed in to change notification settings - Fork 391
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When subscribing to database changes using supabase-py, I see no events, until after about 10 seconds when I get Channel subscription state: RealtimeSubscribeStates.TIMED_OUT.
To check that it's a python problem and not something else, I tried this js code which works fine:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
process.env.SUPABASE_URL,
process.env.SUPABASE_SERVICE_ROLE_KEY
)
const channel = supabase
.channel('schema-db-changes')
.on(
'postgres_changes',
{
event: '*',
schema: 'public',
},
(payload) => console.log(payload)
)
.subscribe()
Reproduction
import asyncio
import supabase
import os
async def watch_db(url, key):
client = await supabase.acreate_client(url, key)
def handle_payload(payload):
print(payload)
def subscribe_callback(state, error):
if error:
print(f"Error subscribing to channel: {error}")
else:
print(f"Channel subscription state: {state}")
channel = client.channel("schema-db-changes")
channel.on_postgres_changes("*", schema="public", callback=handle_payload)
await channel.subscribe(subscribe_callback)
await asyncio.Event().wait()
if __name__ == "__main__":
asyncio.run(
watch_db(os.environ["SUPABASE_URL"], os.environ["SUPABASE_SERVICE_ROLE_KEY"])
)Steps to reproduce
- Set env vars
SUPABASE_URLandSUPABASE_SERVICE_ROLE_KEYto point to a locally running Supabase instance, mine has supabase/realtime:v2.65.2 - Install supabase-py 2.24.0 (I also tried with 2.23.2 and got the same result)
- Run the python code
- Do some DB insertions
Expected: I first see a SUBCRIBED event and then I see the db events
Observed: I see no events, until after about 10 seconds when I get Channel subscription state: RealtimeSubscribeStates.TIMED_OUT
Library affected
supabase-py
Library version
supabase 2.24.0; supabase/realtime:v2.65.2
Python version
Python 3.13.9; Python 3.14.0 on MacOS Tahoe 26.1
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working