Thanks for the explanation!
For some reason, the compiler doesn't detect the problem at the compile time
Should I report this somewhere?
To fix the issue, you can consider making the closures passed to WCSession.sendMessageData(...) sendable, which tells the compiler that the closure can be safely run in any thread
Makes sense. That also works. I created a new PR to show it. Fix Ziqiao Chen
Would it still make sense to mark continuation?
Does it make sense to have both marked as @Sendable?
Is marking the parameters better than doing so to continuation? No real difference?
Does any of it mess with on which Thread the code is run?
It does not seem like it. But hard to tell.
@Sendable data & @Sendable error
ConnectivityManager.swift: sendExample(): called on Thread <NSThread: 0x60000177a340>{number = 7, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): called on Thread <NSThread: 0x60000177a340>{number = 7, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): withCheckedThrowingContinuation called on Thread <NSThread: 0x60000177a340>{number = 7, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): replyHandler called on Thread <NSThread: 0x6000017544c0>{number = 10, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): replyHandler task called on Thread <NSThread: 0x600001720c00>{number = 6, name = (null)}
@Sendable continuation
ConnectivityManager.swift: sendExample(): called on Thread <NSThread: 0x6000017580c0>{number = 3, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): called on Thread <NSThread: 0x6000017580c0>{number = 3, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): withCheckedThrowingContinuation called on Thread <NSThread: 0x6000017580c0>{number = 3, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): replyHandler called on Thread <NSThread: 0x60000171ff00>{number = 11, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): replyHandler task called on Thread <NSThread: 0x60000171c500>{number = 12, name = (null)}
@Sendable continuation & @Sendable data & @Sendable error
ConnectivityManager.swift: sendExample(): called on Thread <NSThread: 0x60000172ed40>{number = 5, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): called on Thread <NSThread: 0x60000172ed40>{number = 5, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): withCheckedThrowingContinuation called on Thread <NSThread: 0x60000172ed40>{number = 5, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): replyHandler called on Thread <NSThread: 0x60000176a240>{number = 12, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): replyHandler task called on Thread <NSThread: 0x60000172ed40>{number = 5, name = (null)}
No @Sendable
ConnectivityManager.swift: sendExample(): called on Thread <NSThread: 0x600001783300>{number = 8, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): called on Thread <NSThread: 0x600001783300>{number = 8, name = (null)}
ConnectivityManager.swift: sendMessageData(_:): withCheckedThrowingContinuation called on Thread <NSThread: 0x600001783300>{number = 8, name = (null)}
Incorrect actor executor assumption