Closed brennanMKE closed 11 months ago
I'm going to close this as "not a bug". The reality is that mach exception handling is a strictly synchronous task and that can't really be changed. You need to scope the synchronous code unit that raises the mach exception or you can't catch it.
Looking at the changes made to Amplify
, linked in this comment thread, I think that's not a bad approach: if synchronously scoping is too difficult on a higher level, then stub out the preconditionFailure
itself – that way you can apply synchronous changes around preconditionFailure
wherever it happens to occur.
The sample package below reproduces the issue. If a precondition fails while running under Swift Concurrency it does not trap the signal which kills the process. The tests cover a couple of functions. One uses a closure and the other is done with
async
. The unit tests show howprecondition
is not caught when run as a Task.