Skip to content

Commit

Permalink
fix(core): potential memory leak in WebSocketClient (#3624)
Browse files Browse the repository at this point in the history
  • Loading branch information
5d authored May 2, 2024
1 parent 0ea629d commit 6f1a089
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ extension WebSocketClient: URLSessionWebSocketDelegate {
extension WebSocketClient {
/// Monitor network status. Disconnect or reconnect when the network drops or comes back online.
private func startNetworkMonitor() {
networkMonitor.publisher.sink(receiveValue: { stateChange in
networkMonitor.publisher.sink(receiveValue: { [weak self] stateChange in
Task { [weak self] in
await self?.onNetworkStateChange(stateChange)
}
Expand Down Expand Up @@ -304,7 +304,7 @@ extension WebSocketClient {
return closeCode
}
.compactMap { $0 }
.sink(receiveCompletion: { _ in }) { closeCode in
.sink(receiveCompletion: { _ in }) { [weak self] closeCode in
Task { [weak self] in await self?.retryOnCloseCode(closeCode) }
}
.store(in: &cancelables)
Expand All @@ -319,7 +319,7 @@ extension WebSocketClient {
}
return false
}
.sink(receiveCompletion: { _ in }) { _ in
.sink(receiveCompletion: { _ in }) { [weak self] _ in
Task { [weak self] in
await self?.retryWithJitter.reset()
}
Expand Down

0 comments on commit 6f1a089

Please sign in to comment.