Skip to content

Supabase Python Client does not close connection & hangs #494

@djmango

Description

@djmango

Describe the bug
The Supabase Python client does not close its connection when it goes out of scope or is deleted, leading to connections persisting after tests are completed in a Django test suite.

To Reproduce
Here's an example of code that reproduces the behavior:

class JWTTest(TestCase):
    def setUp(self):
        self.supabase: SupabaseClient = create_client(os.environ['SUPABASE_URL'], os.environ['SUPABASE_KEY'])

    def tearDown(self):
        pass

    def test_jwt(self):
        # test code...

Steps to reproduce the behavior:

  1. Set up a Django test case that uses the Supabase Python client.
  2. Run a test method that uses the Supabase client.
  3. After the test is completed, the connection to Supabase does not close, preventing Django from cleaning up the test database.

Expected behavior
The Supabase Python client should automatically close its connection when it goes out of scope or is deleted, allowing Django to clean up its test database after tests are run.

Desktop (please complete the following information):

  • OS: Mac OS 13.5
  • Python version: 3.11
  • Supabase Python client version: 1.0.3

Additional context
This issue has caused problems in running Django test suites, as it prevents Django from deleting its test database due to the persistent connection. I haven't found any valid workarounds besides keyboard interrupt (e.g., forcing garbage collection), it would be better if the Supabase client could handle this automatically. Additionally, I tested this in a minimal script that just initializes the Supabase client, and the behavior is the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions