Open
Description
🐞 Bug Report — SupabaseClient.execute()
fails to compile inside @MainActor
context even when the model is Sendable
Package | supabase-swift |
Version | 2.5.1 |
Swift | 6.2 |
Platform / SDK | iOS 26 (device & simulator) |
Build system | Swift Package Manager |
1 · Issue summary
Invoking:
let purpose: SitePurpose = try await supabase
.from(\"site_purpose\")
.select()
.execute() // ← compile-time error
.value
inside a @MainActor
context fails to compile:
Main actor-isolated conformance of 'SitePurpose' to 'Decodable'
cannot satisfy conformance requirement for a 'Sendable' type parameter
This occurs even when SitePurpose
explicitly conforms to Sendable
.
2 · Minimal reproducible example
import Supabase
import Foundation
struct SitePurpose: Decodable, Sendable { // ✅ Sendable
let id: String
let label: String
}
@MainActor // ← actor isolation
final class PurposeVM: ObservableObject {
func fetch() async {
let purpose: SitePurpose = try! await supabase
.from(\"site_purpose\")
.select()
.execute() // ❌ compiler error here
.value
print(purpose)
}
}
3 · Analysis
SupabaseClient
is implemented as anactor
.- Calling an actor method from another actor (
@MainActor
) requires the generic
return type to beSendable
and non-isolated. - Even with
SitePurpose : Sendable
, the compiler rejects the call, suggesting
an implicit extra constraint in the library.
4 · Workarounds
Workaround | Drawback |
---|---|
Wrap call in Task.detached { … } |
Verbose; hides intent, did not work |
Move fetch logic to a non-actor service | Forces architectural change, did not work |
Fetch raw JSON then decode manually | Loses execute<T> convenience |
5 · Expected behaviour
execute()
should compile inside @MainActor
when the model conforms to both
Decodable
and Sendable
.
If the additional constraint is necessary, it should be explicit in the API so
the compiler produces a clear error.
6 · Environment details
swift --version
# Swift version 6.2
# Package version
supabase-swift 2.5.1 via SPM
Thanks 🙏
Happy to test any patch or beta branch—just ping me.