diff --git a/CHANGELOG.md b/CHANGELOG.md index 22102709a30..53bdedaa156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add new `TextLinkDetector` for parsing and detecting links given a string [#2984](https://github.com/GetStream/stream-chat-swift/pull/2984) ### 🐞 Fixed - Fix message link preview showing empty space when no metadata available [#2984](https://github.com/GetStream/stream-chat-swift/pull/2984) -- Fix threading issue in `ConnectionRepository` [#2985](https://github.com/GetStream/stream-chat-swift/pull/2985) +- Fix threading issues in `ConnectionRepository` [#2985](https://github.com/GetStream/stream-chat-swift/pull/2985), [#2987](https://github.com/GetStream/stream-chat-swift/pull/2987) - Fix threading issues in `AuthenticationRepository` [#2986](https://github.com/GetStream/stream-chat-swift/pull/2986) ## StreamChatUI diff --git a/Sources/StreamChat/Repositories/ConnectionRepository.swift b/Sources/StreamChat/Repositories/ConnectionRepository.swift index d411ac4e937..7db3467d539 100644 --- a/Sources/StreamChat/Repositories/ConnectionRepository.swift +++ b/Sources/StreamChat/Repositories/ConnectionRepository.swift @@ -216,7 +216,7 @@ class ConnectionRepository { connectionId: String?, shouldNotifyWaiters: Bool ) { - let waiters: [String: (Result) -> Void] = connectionQueue.sync { + let waiters: [String: (Result) -> Void] = connectionQueue.sync(flags: .barrier) { _connectionId = connectionId guard shouldNotifyWaiters else { return [:] } let waiters = _connectionIdWaiters diff --git a/Tests/StreamChatTests/Repositories/ConnectionRepository_Tests.swift b/Tests/StreamChatTests/Repositories/ConnectionRepository_Tests.swift index 1d984c34d1d..4421857e40b 100644 --- a/Tests/StreamChatTests/Repositories/ConnectionRepository_Tests.swift +++ b/Tests/StreamChatTests/Repositories/ConnectionRepository_Tests.swift @@ -470,7 +470,7 @@ final class ConnectionRepository_Tests: XCTestCase { XCTAssertEqual(result?.value, connectionId) } - func test_connectionId_doesNotDeadlock() { + func test_connectionId_triggersCompletions_whenConcurrentlyCalled() { let iterations = 100 let expectations = (0..