Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelling before continuation #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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