Skip to content
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

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

Closed
Slumberdac opened this issue Aug 16, 2024 · 2 comments · Fixed by #902
Labels
bug Something isn't working

Comments

@Slumberdac
Copy link

Slumberdac commented Aug 16, 2024

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()
@Slumberdac Slumberdac added the bug Something isn't working label Aug 16, 2024
@Slumberdac
Copy link
Author

I tried jankily adding one line locally that runs realtime.connect() which seemed to solve the issue on supabase's side (realtime then causes an AttributeError for which i've also opened an issue) but I'm sure that this is doomed to happen to others so I come to you to see if this is in fact an accident or if it turns out my project needs to be adapted (I couldn't find anything in the documentation regarding this)

@AzulGarza
Copy link

i had the same problem, i think this is related to the latest releases. downgrading to supabase<2.7.0 fixed the problem.

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