Building ably-chat-swift with Xcode 26.4 / Swift 6.2 fails in Sources/AblyChat/TypingOperationQueue.swift because of stricter actor-isolation/sendability
checking.
Compiler error
TypingOperationQueue.swift:96:38: error: sending 'pendingRequest' risks causing data races
await pendingRequest.performOperation()
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
note: sending main actor-isolated 'pendingRequest' to nonisolated instance method 'performOperation()' risks causing data races between nonisolated and main
actor-isolated uses
Code
TypingOperationQueue is @mainactor, and the failure happens in didFinishExecutingOperation() when a pending request is executed inside a Task:
@MainActor
internal class TypingOperationQueue<Failure: Error> {
private struct Request {
func performOperation() async {
let result = await operation()
complete(with: result)
}
func complete(with result: Result<Void, Failure>) {
continuation.resume(returning: result)
}
}
private func didFinishExecutingOperation() {
if let pendingRequest {
state = .executing(pendingRequest: nil)
Task {
await pendingRequest.performOperation()
didFinishExecutingOperation()
}
} else {
state = .idle
}
}
}
What fixed it locally
We were able to get the package compiling by explicitly marking the nested Request methods as @mainactor and making the task main-actor isolated as well:
@MainActor
func performOperation() async { ... }
@MainActor
func complete(with result: Result<Void, Failure>) { ... }
Task { @MainActor in
await pendingRequest.performOperation()
didFinishExecutingOperation()
}
Environment
- Xcode 26.4
- Swift 6.2
- iOS simulator build
- Reproduced with ably-chat-swift 1.2.0
┆Issue is synchronized with this Jira Task by Unito
Building
ably-chat-swiftwith Xcode 26.4 / Swift 6.2 fails inSources/AblyChat/TypingOperationQueue.swiftbecause of stricter actor-isolation/sendabilitychecking.
Compiler error
Code
TypingOperationQueue is @mainactor, and the failure happens in didFinishExecutingOperation() when a pending request is executed inside a Task:
What fixed it locally
We were able to get the package compiling by explicitly marking the nested Request methods as @mainactor and making the task main-actor isolated as well:
Environment
┆Issue is synchronized with this Jira Task by Unito