Skip to content

Fix race conditions#20

Merged
atdrendel merged 3 commits into
mainfrom
fix-race-condition
Apr 20, 2026
Merged

Fix race conditions#20
atdrendel merged 3 commits into
mainfrom
fix-race-condition

Conversation

@atdrendel
Copy link
Copy Markdown
Contributor

@atdrendel atdrendel commented Apr 19, 2026

  • Fix race condition in WebSocket.messages
  • Fix race condition in SystemURLSession callbacks
  • Ensure close code is always reported correctly
  • Cancelling SystemWebSocket.open throws CancellationError

Copilot AI review requested due to automatic review settings April 19, 2026 23:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates WebSocket.messages to eliminate a race condition by replacing the prior AsyncStream-creation logic with AsyncStream.makeStream(), wiring publisher completion/cancellation into the stream lifecycle, and cancelling the Combine subscription when the async stream terminates.

Changes:

  • Re-implement WebSocket.messages using AsyncStream.makeStream() and a Combine sink.
  • Finish the async stream on publisher completion/cancellation and cancel the Combine subscription on async stream termination.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/WebSocket/WebSocket.swift Outdated
Comment thread Sources/WebSocket/WebSocket.swift
@atdrendel atdrendel changed the title Fix race condition in WebSocket.messages Fix race conditions Apr 20, 2026
@atdrendel atdrendel merged commit 3a934c8 into main Apr 20, 2026
1 check passed
@atdrendel atdrendel deleted the fix-race-condition branch April 20, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants