@@ -436,13 +436,15 @@ enum FunctionsConstants {
436
436
withObject data: Any ? ,
437
437
options: HTTPSCallableOptions ? ,
438
438
timeout: TimeInterval ,
439
- completion: @escaping ( ( Result < HTTPSCallableResult , Error > ) -> Void ) ) {
439
+ completion: @escaping @ MainActor ( Result < HTTPSCallableResult , Error > ) -> Void ) {
440
440
// Get context first.
441
441
contextProvider. getContext ( options: options) { context, error in
442
442
// Note: context is always non-nil since some checks could succeed, we're only failing if
443
443
// there's an error.
444
444
if let error {
445
- completion ( . failure( error) )
445
+ DispatchQueue . main. async {
446
+ completion ( . failure( error) )
447
+ }
446
448
} else {
447
449
self . callFunction ( url: url,
448
450
withObject: data,
@@ -459,7 +461,7 @@ enum FunctionsConstants {
459
461
options: HTTPSCallableOptions ? ,
460
462
timeout: TimeInterval ,
461
463
context: FunctionsContext ,
462
- completion: @escaping ( ( Result < HTTPSCallableResult , Error > ) -> Void ) ) {
464
+ completion: @escaping @ MainActor ( Result < HTTPSCallableResult , Error > ) -> Void ) {
463
465
let fetcher : GTMSessionFetcher
464
466
do {
465
467
fetcher = try makeFetcher (
@@ -762,7 +764,7 @@ enum FunctionsConstants {
762
764
}
763
765
764
766
private func callableResult( fromResponseData data: Data ,
765
- endpointURL url: URL ) throws -> HTTPSCallableResult {
767
+ endpointURL url: URL ) throws -> sending HTTPSCallableResult {
766
768
let processedData = try processedData ( fromResponseData: data, endpointURL: url)
767
769
let json = try responseDataJSON ( from: processedData)
768
770
let payload = try serializer. decode ( json)
@@ -784,7 +786,7 @@ enum FunctionsConstants {
784
786
return data
785
787
}
786
788
787
- private func responseDataJSON( from data: Data ) throws -> Any {
789
+ private func responseDataJSON( from data: Data ) throws -> sending Any {
788
790
let responseJSONObject = try JSONSerialization . jsonObject ( with: data)
789
791
790
792
guard let responseJSON = responseJSONObject as? NSDictionary else {
0 commit comments