Allow in-progress form upload to be interrupted on cancel#7203
Open
grzesiek2010 wants to merge 9 commits into
Open
Allow in-progress form upload to be interrupted on cancel#7203grzesiek2010 wants to merge 9 commits into
grzesiek2010 wants to merge 9 commits into
Conversation
grzesiek2010
marked this pull request as ready for review
April 23, 2026 20:07
seadowg
reviewed
Apr 29, 2026
grzesiek2010
force-pushed
the
COLLECT-7188
branch
2 times, most recently
from
June 22, 2026 16:55
6ad8524 to
680affb
Compare
seadowg
requested changes
Jul 13, 2026
| * Unlike other [FormUploadException]s this should not be reported to the user as an error - it | ||
| * simply stops the current submission attempt. | ||
| */ | ||
| class FormUploadInterruptedException : FormUploadException("Upload interrupted") |
Member
There was a problem hiding this comment.
I'm wondering if we can introduce a generalization for this instead that builds on Cancellable - could be a CancellationToken class like this:
class CancellationToken : Cancellable {
private var cancelled = false
override fun cancel() {
cancelled = true
}
fun ensureActive() {
if (isCancelled()) {
throw CancelledException()
}
}
}Or just something similar!
Member
Author
There was a problem hiding this comment.
I gave this a go, but I'd lean towards keeping the current approach. A CancellationToken would complicate the code, and it would decouple cancellation from the coroutine, so we'd drop the built-in mechanism (isCancelled = { !isActive }) we get for free.
grzesiek2010
force-pushed
the
COLLECT-7188
branch
from
July 15, 2026 23:30
680affb to
c852aa9
Compare
grzesiek2010
force-pushed
the
COLLECT-7188
branch
from
July 15, 2026 23:32
c852aa9 to
ec5ddc3
Compare
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.
Closes #7188
Why is this the best possible solution? Were any other approaches considered?
In #7008 we reworked the process of uploading filled forms manually by replacing the old Android AsyncTask with coroutines. The old approach was checking if the task is active at the beginning of every iteration (for every selected form) and we implemented the same behavior in the coroutine-based approach. However, it turns out that the old AsyncTask, when canceled, was also interrupting the worker thread, which had the effect of canceling a form upload that was already in progress (mid-upload). We missed that in the new approach, and now I have fixed it by using
runInterruptible.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
We need to test the same things as in #7008.
Do we need any specific form for testing your changes? If so, please attach one.
Any form.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest