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

fix: race condition when accessing SupabaseClient #386

Merged
merged 1 commit into from
May 15, 2024
Merged

Conversation

grdsdev
Copy link
Collaborator

@grdsdev grdsdev commented May 15, 2024

What kind of change does this PR introduce?

I wasn't able to reproduce it, but I have an assumption that these changes may fix the following crashes.

Fix #239
Fix #385

What is the current behavior?

Inner clients from SupabaseClient were defined as lazy var, but lazy var isn't thread-safe in Swift, this was probably causing some crashes when accessed from different threads.

We also relied on it to mark the SupabaseClient class as @unchecked Sendable.

What is the new behavior?

Moved inner clients to a LockIsolated and made SupabaseClient conform to Sendable.

@grdsdev grdsdev requested a review from dshukertjr May 15, 2024 08:44
@grdsdev grdsdev merged commit 811e222 into main May 15, 2024
11 checks passed
@grdsdev grdsdev deleted the fix/crash branch May 15, 2024 10:05
@kevlust
Copy link

kevlust commented May 15, 2024

@grdsdev you're awesome. Thanks for coming up with this fix so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants