Skip to content

Async client throws error with persistent storage #1528

Description

@Agente3z

Describe the bug

When you try to change the password using a client created with acreate_client, and await it, it throws this error:

Traceback (most recent call last):
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/uvicorn/protocols/http/httptools_impl.py", line 421, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.scope, self.receive, self.send
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/uvicorn/middleware/proxy_headers.py", line 56, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/fastapi/applications.py", line 1159, in __call__
    await super().__call__(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/applications.py", line 90, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/middleware/cors.py", line 96, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/middleware/cors.py", line 154, in simple_response
    await self.app(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/routing.py", line 660, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/routing.py", line 680, in app
    await route.handle(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/fastapi/routing.py", line 134, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/fastapi/routing.py", line 120, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/fastapi/routing.py", line 674, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/fastapi/routing.py", line 328, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/agente3z/.../.../app/routers/auth.py", line 146, in change_password
    await supa_svc.change_password(request.email, request.oldPassword, request.newPassword)
  File "/home/agente3z/.../.../app/services/supabase_service.py", line 109, in change_password
    await client.auth.sign_in_with_password({"email": email, "password": old_password})
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/supabase_auth/_async/gotrue_client.py", line 299, in sign_in_with_password
    await self._remove_session()
  File "/home/agente3z/.../.../.venv/lib64/python3.14/site-packages/supabase_auth/_async/gotrue_client.py", line 981, in _remove_session
    await self._storage.remove_item(self._storage_key)
TypeError: 'NoneType' object can't be awaited

Reproduction

async def create_anon_client() -> AsyncClient:
    return await acreate_client(
        SUPABASE_URL,
        SUPABASE_ANON_KEY,
        ClientOptions(
            auto_refresh_token=True,
            persist_session=True,
        ),

async def change_password(self, email: str, old_password: str, new_password: str) -> None:
    try:
        client = await create_anon_client()
        await client.auth.sign_in_with_password({"email": email, "password": old_password})
        await client.auth.update_user({"password": new_password, "current_password": old_password})
    except AuthError as err:
        self._handle_api_error(err)

Steps to reproduce

No response

Library affected

supabase-auth

Library version

supabase 2.30.1

Python version

Python 3.14.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions