test(supabase): verify shared YAJsonIsolate instance across sub-clients#1345
Merged
test(supabase): verify shared YAJsonIsolate instance across sub-clients#1345
Conversation
Adds tests to explicitly verify that SupabaseClient shares a single YAJsonIsolate instance with PostgrestClient and FunctionsClient (rather than each spawning their own isolate), and that dispose() correctly cleans up the shared isolate. Linear: SDK-815 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mandarini
approved these changes
Apr 3, 2026
Collaborator
|
Actually, I would disagree with the current behavior. If you pass a custom isolate to the supabase client, I don't think it should dispose it. Passing a custom one is a way to make isolate handling between many clients more efficient, which is not possible if it gets disposed by the client. The sublibraries like functions and postgrest only dispose their own isolate. While it is needed there, because the isolate typically comes from the supabase client, I think this design should be applied to the supabase client as well. |
When a custom YAJsonIsolate is passed to SupabaseClient, the caller owns its lifecycle and may be sharing it across multiple clients. Disposing it from SupabaseClient.dispose() breaks that pattern. Mirrors the _hasCustomIsolate guard already used in PostgrestClient and FunctionsClient. Linear: SDK-815 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Vinzent03
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SupabaseClientshares a singleYAJsonIsolateacrossPostgrestClientandFunctionsClient(the implementation was already correct)SupabaseClient.dispose()is calledSupabaseClientwithout a custom isolate results in correct shared lifecycle managementRoot Cause Analysis
The issue reported that each client was creating its own
YAJsonIsolate. Reviewing the current code:supabase_client.dart:142— creates_isolate = isolate ?? (YAJsonIsolate()..initialize())supabase_client.dart:306— passesisolate: _isolatetoPostgrestClientsupabase_client.dart:316— passesisolate: _isolatetoFunctionsClientsupabase_client.dart:277— disposes_isolateindispose()The implementation was already correct. This PR adds test coverage to lock in that behavior.
Testing
packages/supabase/test/client_test.dartAcceptance Criteria
YAJsonIsolatecreated perSupabaseClientinstance (already implemented)SupabaseClient.dispose()cleans up the shared isolate (already implemented)Closes: SDK-815
🤖 Generated with Claude Code