[question]: (how to) re-introduce concurrent iteration runtime error for `AsyncStream`

the documentation for the AsyncIterators of AsyncStream and AsyncThrowingStream both include the following form of admonition (emphasis mine):

This type doesn’t conform to Sendable. Don’t use it from multiple concurrent contexts. It is a programmer error to invoke next() from a concurrent context that contends with another such call, which results in a call to fatalError().

however, only one of these two types (AsyncThrowingStream) currently implements the alluded-to runtime error if such a state is detected.

this difference appears incidental, and it would benefit developers to have both behavioral consistency across the throwing and non-throwing stream variants, as well as accurate documentation.

the removal of the runtime error appears to have been introduced in this PR, but it is unclear if it was intentional (i would guess not). according to github, this means it first shipped in Swift 5.7.

addressing this would presumably be quite straightforward (just need to revert a single line), but it's unclear to me what the actual process for realizing that is (open a PR? file a radar? evolution proposal?). so i ask – how can such a change be made?

1 Like