Skip to content

Commit 9027e5d

Browse files
committed
Merge branch 'fix/swift_concurrency' into 'develop'
fix: SWIFT TASK CONTINUATION MISUSE: awaitResultWithID(_:) leaked its continuation! See merge request papers/airgap/airgap-wallet!773
2 parents 0ba7df9 + 655980b commit 9027e5d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ios/App/App/Helpers/JS.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ class JSAsyncResult: NSObject, Identifiable, WKScriptMessageHandler {
5454
}
5555

5656
func awaitResultWithID(_ id: String) async throws -> Any {
57-
if let result = await resultManager.result[id] {
58-
return try result.get()
59-
}
60-
6157
return try await withCheckedThrowingContinuation { continuation in
6258
Task {
63-
await listenerRegistry.add(forID: id) { result in
59+
if let result = await resultManager.result[id] {
6460
continuation.resume(with: result)
61+
} else {
62+
await listenerRegistry.add(forID: id) { result in
63+
continuation.resume(with: result)
64+
}
6565
}
6666
}
6767
}

0 commit comments

Comments
 (0)