Skip to content

Commit 29473ed

Browse files
committed
ensure flush completion handler is always called
1 parent cf8eb4c commit 29473ed

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/MixpanelInstance.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,16 @@ extension MixpanelInstance {
856856
}
857857
trackingQueue.async { [weak self, completion] in
858858
guard let self = self else {
859+
if let completion = completion {
860+
DispatchQueue.main.async(execute: completion)
861+
}
859862
return
860863
}
861864

862865
if let shouldFlush = self.delegate?.mixpanelWillFlush(self), !shouldFlush {
866+
if let completion = completion {
867+
DispatchQueue.main.async(execute: completion)
868+
}
863869
return
864870
}
865871

@@ -873,6 +879,9 @@ extension MixpanelInstance {
873879

874880
self.networkQueue.async { [weak self, completion] in
875881
guard let self = self else {
882+
if let completion = completion {
883+
DispatchQueue.main.async(execute: completion)
884+
}
876885
return
877886
}
878887
self.flushQueue(eventQueue, type: .events)

0 commit comments

Comments
 (0)