fix: [SDK-4995] always run suspendifyWithCompletion onComplete - #2764
Open
fadi-george wants to merge 1 commit into
Open
fadi-george wants to merge 1 commit into
fadi-george wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)8/9 touched executable lines covered (88.9% — requires ≥ 80%) |
abdulraqeeb33
approved these changes
Sep 24, 2026
| } | ||
| } | ||
| // invokeOnCompletion also fires when the job is cancelled before its body starts. | ||
| job.invokeOnCompletion { |
Contributor
There was a problem hiding this comment.
invokeOnCompletion runs on the completing thread, or inline on the caller if the job is already finished. suspendifyOnIO's KDoc still says onComplete runs on the background thread.
| }, | ||
| ) | ||
|
|
||
| latch.await() |
Contributor
There was a problem hiding this comment.
latch.await() has no timeout, so a regression hangs the suite. This also does not cover cancel-before-start, which is the case the change is for.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
suspendifyWithCompletionalways runsonComplete, including when the block throws or the job is cancelled before it starts.Details
Motivation
Split out of #2712. Callers that release a resource in
onComplete(for example aPendingResult.finish()) could leak it when the block threw, becauseonCompleteonly ran on success.Scope
onCompleteis registered withinvokeOnCompletion, so it runs on success, failure, and pre-start cancellation.onCompleteare logged instead of escaping.onCompletetoday, so there is no behavior change for existing SDK paths.Testing
Unit testing
Added a test that
onCompleteruns when the block throws.Manual testing
Not tested on device; this is a threading helper with no production caller of the changed parameter.
Affected code checklist
Checklist
Overview
Testing
Final pass