Could be related to the issues I'm having detecting cancellation of subtasks in AsyncStream and Cancellation. Part of the issue here may be that you aren't waiting for cancellation to complete, and that the behavior of Task
in that case isn't documented. isCancelled
is synchronous, so I'd hope the updating of the state would be too, but there may be a race here.