feat(swift): transactions run withTaskCancellationHandler [WPB-27117]#2340
Open
SimonThormeyer wants to merge 16 commits into
Open
feat(swift): transactions run withTaskCancellationHandler [WPB-27117]#2340SimonThormeyer wants to merge 16 commits into
withTaskCancellationHandler [WPB-27117]#2340SimonThormeyer wants to merge 16 commits into
Conversation
SimonThormeyer
force-pushed
the
simon/feat/swift-cancellation
branch
2 times, most recently
from
July 17, 2026 12:06
1e75636 to
7bfd6a8
Compare
withTaskCancellationHandler [WPB-27117]
SimonThormeyer
marked this pull request as ready for review
July 17, 2026 12:08
SimonThormeyer
force-pushed
the
simon/feat/swift-cancellation
branch
from
July 17, 2026 12:14
7bfd6a8 to
8597d5a
Compare
This allows the `CoreCryptoFfi` struct to store the current cancellation token and race an mls transport future against its cancellation.
This future is created from the cancellation token and will resolve when someone calls `.cancel()` on the token.
…d `MlsTransportShim` ...And make `MlsTransportShim` race against token cancellation in `send_commit_bundle()`.
We need `CoreCryptoFfi` to be aware if it has a `PkiEnvironment` so that it can use the cancellation slot to store the token in when starting a transaction.
Upon creation of the transaction, the PKI environment also receives the cancellation slot which gets filled with the cancellation token for the duration of the transaction. The PKI env hooks, which may be as long-running as mls transport callbacks, will then also race against cancellation of the token.
And use it to gate all items added in this PR.
Also, use an extra target directory for the swift uniffi binary to avoid it being confused with the kotlin one.
SimonThormeyer
force-pushed
the
simon/feat/swift-cancellation
branch
from
July 17, 2026 12:29
9f7bb84 to
c65e405
Compare
We're using an entirely seperate flow now when generating on macOS
SimonThormeyer
force-pushed
the
simon/feat/swift-cancellation
branch
from
July 17, 2026 12:38
78a095f to
c19624b
Compare
typfel
requested changes
Jul 17, 2026
|
|
||
| // Assert that cancellation is triggered without waiting for either callback result. | ||
| do { | ||
| try await transactionTask.value |
Member
There was a problem hiding this comment.
We have a XCTAssertThrowsErrorAsync helper you can use here.
Member
Author
There was a problem hiding this comment.
When trying to use it like this
let expectedError = CancellationError()
// Assert that cancellation is triggered without waiting for either callback result.
await XCTAssertThrowsErrorAsync(
expectedError,
when: {
try await transactionTask.value
}
)I get
Instance method 'XCTAssertThrowsErrorAsync(_:when:_:file:line:)' requires that 'CancellationError' conform to 'Equatable'
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.
Make core crypto ffi transactions cancellable and run the ffi transaction
withTaskCancellationHandlerin the wrapper.