Skip to content

Fix flakey testHalfCloseOwnOutputWithPopulatedBuffer on iOS sim#3551

Merged
rnro merged 1 commit intoapple:mainfrom
rnro:testHalfCloseOwnOutputWithPopulatedBuffer
Mar 17, 2026
Merged

Fix flakey testHalfCloseOwnOutputWithPopulatedBuffer on iOS sim#3551
rnro merged 1 commit intoapple:mainfrom
rnro:testHalfCloseOwnOutputWithPopulatedBuffer

Conversation

@rnro
Copy link
Copy Markdown
Contributor

@rnro rnro commented Mar 16, 2026

Motivation

  • testHalfCloseOwnOutputWithPopulatedBuffer asserts that writing to a half-closed channel produces ChannelError.outputClosed. However, after flushing the buffered write and the FIN, the remote peer can process both and fully close the connection before the subsequent write is processed. When this happens the channel is fully closed and the write fails with .ioOnClosedChannel instead.
  • This race seems to be more likely on iOS simulators in CI.

Modifications

  • Accept either .outputClosed or .ioOnClosedChannel as valid errors from the post-half-close write.

Result

  • The test no longer flakes on iOS simulator CI runs.

Motivation

* `testHalfCloseOwnOutputWithPopulatedBuffer` asserts that writing to a
  half-closed channel produces `ChannelError.outputClosed`. However, after
  flushing the buffered write and the FIN, the remote peer can process both
  and fully close the connection before the subsequent write is processed.
  When this happens the channel is fully closed and the write fails with
  `.ioOnClosedChannel` instead. This race seems to be more likely on iOS
  simulators.

Modifications

* Accept either `.outputClosed` or `.ioOnClosedChannel` as valid errors
  from the post-half-close write.

Result

* The test no longer flakes on iOS simulator CI runs.
@rnro rnro added the semver/none No version bump required. label Mar 16, 2026
@rnro rnro merged commit 0e7d4e9 into apple:main Mar 17, 2026
52 of 54 checks passed
@rnro rnro deleted the testHalfCloseOwnOutputWithPopulatedBuffer branch March 17, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver/none No version bump required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants