Describe the bug
An auth-state callback that unsubscribes itself causes sign_out() to raise RuntimeError: dictionary changed size during iteration. Other registered listeners then miss the sign-out event. This affects both SyncGoTrueClient and AsyncGoTrueClient, for example when a one-shot listener unregisters after handling its first event.
Reproduction
No running Supabase instance or credentials are needed:
from supabase_auth import SyncGoTrueClient
client = SyncGoTrueClient(
url="http://localhost:9998",
auto_refresh_token=False,
persist_session=False,
)
received = []
def once(event, session):
subscription.unsubscribe()
subscription = client.on_auth_state_change(once)
client.on_auth_state_change(lambda event, session: received.append(event))
client.sign_out()
assert received == ["SIGNED_OUT"]
Expected: sign-out completes, the second listener receives SIGNED_OUT, and the unsubscribed listener does not receive subsequent events.
Actual: _notify_all_subscribers() iterates a live dictionary view; subscription.unsubscribe() removes an entry during that iteration, causing RuntimeError before the second listener is called.
Environment
- Library:
supabase_auth 2.31.0
- Reproduced on upstream main
bb7ecc5fb86f5f8729c40a3885c6154d9b9f6262
- Python: 3.13.12
Describe the bug
An auth-state callback that unsubscribes itself causes
sign_out()to raiseRuntimeError: dictionary changed size during iteration. Other registered listeners then miss the sign-out event. This affects bothSyncGoTrueClientandAsyncGoTrueClient, for example when a one-shot listener unregisters after handling its first event.Reproduction
No running Supabase instance or credentials are needed:
Expected: sign-out completes, the second listener receives
SIGNED_OUT, and the unsubscribed listener does not receive subsequent events.Actual:
_notify_all_subscribers()iterates a live dictionary view;subscription.unsubscribe()removes an entry during that iteration, causingRuntimeErrorbefore the second listener is called.Environment
supabase_auth2.31.0bb7ecc5fb86f5f8729c40a3885c6154d9b9f6262