Skip to content

Auto-Reconnect is broken when reconnect is triggered by _listen #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
Sandr0x00 opened this issue Jan 17, 2025 · 1 comment · Fixed by #262
Closed
2 tasks done

Auto-Reconnect is broken when reconnect is triggered by _listen #258

Sandr0x00 opened this issue Jan 17, 2025 · 1 comment · Fixed by #262
Labels
bug Something isn't working

Comments

@Sandr0x00
Copy link
Contributor

Sandr0x00 commented Jan 17, 2025

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

When using the example code (test_postgres_changes), the DELETE change triggers our function. As expected.
If we have an automatic reconnect, then we can get lucky and the heartbeat might reconnect (https://github.com/supabase/realtime-py/blob/main/realtime/_async/client.py#L202-L214). Then things keep working.
But if we are unlucky, then the listen function reconnects us (https://github.com/supabase/realtime-py/blob/main/realtime/_async/client.py#L102-L105). In this case we will NEVER receive any realtime-update again.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to example
  2. npx supabase start
  3. Setup a table todos (use /tests/supabase/migrations/20240810125543_init.sql)
  4. Comment out broken filter for INSERT change (see Example is broken #257) in app.py (https://github.com/supabase/realtime-py/blob/main/example/app.py#L135)
  5. Comment out https://github.com/supabase/realtime-py/blob/main/example/app.py#L135 as we don't care about broadcast events for this bug.
  6. Insert, update and delete something => see that it works
  7. Force a disconnect using docker container restart supabase_realtime_realtime-py-example
  8. Check output if INFO - Rejoining to: realtime:test-postgres-changes is in the output. if yes, then things continue to work as _heartbeat did the reconnect
  9. If there is no "rejoining"-output, then _listen did the reconnect and then the realtime connection is broken forever.

Expected behavior

Auto-Reconnect to work.

System information

Latest supabase 2.6.8

npx supabase services

        SERVICE IMAGE      │      LOCAL       │ LINKED
  ─────────────────────────┼──────────────────┼─────────
    supabase/postgres      │ 15.8.1.020       │ -
    supabase/gotrue        │ v2.167.0         │ -
    postgrest/postgrest    │ v12.2.0          │ -
    supabase/realtime      │ v2.33.70         │ -
    supabase/storage-api   │ v1.14.5          │ -
    supabase/edge-runtime  │ v1.66.4          │ -
    supabase/studio        │ 20250113-83c9420 │ -
    supabase/postgres-meta │ v0.84.2          │ -
    supabase/logflare      │ 1.4.0            │ -
    supabase/supavisor     │ 1.1.56           │ -
@PatidarManas
Copy link

PatidarManas commented Jan 22, 2025

Facing same issue, need this fix to get merged to production
__main__ ERROR Unhandled exception in main: 'AsyncRealtimeClient' object has no attribute '_connect'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants