Skip to content

Commit

Permalink
fix: Assign websocket callback queue before connecting (apollographql…
Browse files Browse the repository at this point in the history
  • Loading branch information
calvincestari authored and gh-action-runner committed Oct 31, 2024
1 parent d3ed72b commit 0adf025
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/ApolloWebSocket/WebSocketTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,14 @@ public class WebSocketTransport {
self.addApolloClientHeaders(to: &self.websocket.request)

self.websocket.delegate = self
// Keep the assignment of the callback queue before attempting to connect. There is the
// potential of a data race if the connection fails early and the disconnect logic reads
// the callback queue while it's being set.
self.websocket.callbackQueue = processingQueue

if config.connectOnInit {
self.websocket.connect()
}
self.websocket.callbackQueue = processingQueue
}

public func isConnected() -> Bool {
Expand Down

0 comments on commit 0adf025

Please sign in to comment.