Skip to content

Commit

Permalink
Merge branch 'fix/swift_concurrency' into 'develop'
Browse files Browse the repository at this point in the history
fix: SWIFT TASK CONTINUATION MISUSE: awaitResultWithID(_:) leaked its continuation!

See merge request papers/airgap/airgap-wallet!773
  • Loading branch information
godenzim committed Sep 23, 2024
2 parents 0ba7df9 + 655980b commit 9027e5d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ios/App/App/Helpers/JS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class JSAsyncResult: NSObject, Identifiable, WKScriptMessageHandler {
}

func awaitResultWithID(_ id: String) async throws -> Any {
if let result = await resultManager.result[id] {
return try result.get()
}

return try await withCheckedThrowingContinuation { continuation in
Task {
await listenerRegistry.add(forID: id) { result in
if let result = await resultManager.result[id] {
continuation.resume(with: result)
} else {
await listenerRegistry.add(forID: id) { result in
continuation.resume(with: result)
}
}
}
}
Expand Down

0 comments on commit 9027e5d

Please sign in to comment.