Skip to content

Conversation

@hactar
Copy link

@hactar hactar commented Feb 2, 2024

If one cancels a location task before it completes, the console shows an error before continuation.resume is never called:

SWIFT TASK CONTINUATION MISUSE: run() leaked its continuation!

You can test this by not keeping a reference to your task, for example:

    func refreshNearbyReports() async throws {
        
        do {
            let locationManager = Location()
            let location = try await locationManager.requestLocation()
       ...
   }

async let _ = try await refreshNearbyReports() // All tasks associated with this are immediately cancelled. 

This code change adds a new error case and calls .resume with it to ensure that the continuation does not leak if cancelled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant