← All tasks
pythonsupabase/supabase-py #898Not a task: already works

Causing an auth event raises NotConnectedError because realtime.connect() isn't called beforehand

envgap__supabase__supabase-py-898

01 / FAILURE SIGNATURE

As reported upstream

realtime.exceptions.NotConnectedError: A WS connection has not been established. Ensure you call RealtimeClient.connect() before calling RealtimeClient.set_auth()
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
bc582b056e8caabc343173ad3e79397c0a1fd048
Manifest
pyproject.toml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

supabase/supabase-py #898 · read the original issue
# Bug report



## Describe the bug



Causing an auth event raises NotConnectedError because realtime.connect() isn't called beforehand.

For example, trying to Sign up a user through supabase.auth.sign_up(credentials) makes gotrue notify subscribers of the event. Supabase listens for the event and tries to run set_auth() without connecting and then crashes the application.



## To Reproduce



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



1. Initialize a supabase client

2. Try signing up a new user

3. Client tries to run self.realtime.set_auth(access_token) without calling self.realtime.connect() first

4. NotConnectedError gets raised 



## Expected behavior



A new user should be created without rising any errors



## Screenshots



If applicable, add screenshots to help explain your problem.



## System information



- OS: [e.g. macOS, Windows]

- Browser (if applies) [e.g. chrome, safari]

- Version of supabase-js: [e.g. 6.0.2]

- Version of Node.js: [e.g. 10.10.0]



## Traceback



```

  File "/mnt/c/Users/Jacob/Documents/GitHub/user-api/app/api/auth.py", line 44, in signup_user

    session = settings.supabase.auth.sign_up(credentials.model_dump()).session

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/slumby/.local/share/virtualenvs/user-api-Jy_0pb3R/lib/python3.12/site-packages/gotrue/_sync/gotrue_client.py", line 237, in sign_up

    self._notify_all_subscribers("SIGNED_IN", response.session)

  File "/home/slumby/.local/share/virtualenvs/user-api-Jy_0pb3R/lib/python3.12/site-packages/gotrue/_sync/gotrue_client.py", line 991, in _notify_all_subscribers

    subscription.callback(event, session)

  File "/home/slumby/.local/share/virtualenvs/user-api-Jy_0pb3R/lib/python3.12/site-packages/supabase/_sync/client.py", line 300, in _listen_to_auth_events

    self.realtime.set_auth(access_token)

  File "/home/slumby/.local/share/virtualenvs/user-api-Jy_0pb3R/lib/python3.12/site-packages/realtime/_sync/client.py", line 30, in wrapper

    raise NotConnectedError(func.__name__)

realtime.exceptions.NotConnectedError: A WS connection has not been established. Ensure you call RealtimeClient.connect() before calling RealtimeClient.set_auth()

```

Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]