Skip to content

Commit

Permalink
fix: SWIFT TASK CONTINUATION MISUSE: awaitResultWithID(_:) leaked its…
Browse files Browse the repository at this point in the history
… continuation!
IsaccoSordo committed Sep 23, 2024
1 parent 0ba7df9 commit 655980b
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
@@ -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)
}
}
}
}

0 comments on commit 655980b

Please sign in to comment.