Skip to content

Commit

Permalink
fix continuation being missused
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed May 3, 2024
1 parent fd02b0a commit 590394c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion Sources/WalletConnectRelay/Dispatching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ final class Dispatcher: NSObject, Dispatching {
var cancellable: AnyCancellable?
cancellable = Publishers.CombineLatest(socketConnectionStatusPublisher, networkConnectionStatusPublisher)
.filter { $0.0 == .connected && $0.1 == .connected }
.first()
.setFailureType(to: NetworkError.self)
.timeout(.seconds(defaultTimeout), scheduler: concurrentQueue, customError: { .connectionFailed })
.sink(receiveCompletion: { [unowned self] result in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ class AutomaticSocketConnectionHandler {
// Start a timer for the fallback mechanism
let timer = DispatchSource.makeTimerSource(queue: concurrentQueue)
timer.schedule(deadline: .now() + .seconds(defaultTimeout))
timer.setEventHandler { [unowned self] in
timer.setEventHandler { [weak self] in
guard let self = self else {
timer.cancel()
return
}
if !self.socket.isConnected {
self.logger.debug("Connection timed out, initiating fallback...")
self.socketUrlFallbackHandler.handleFallbackIfNeeded(error: .connectionFailed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ class ManualSocketConnectionHandler: SocketConnectionHandler {
// Start a timer for the fallback mechanism
let timer = DispatchSource.makeTimerSource(queue: concurrentQueue)
timer.schedule(deadline: .now() + .seconds(defaultTimeout))
timer.setEventHandler { [unowned self] in
timer.setEventHandler { [weak self] in
guard let self = self else {
timer.cancel()
return
}
if !self.socket.isConnected {
self.logger.debug("Connection timed out, initiating fallback...")
self.socketUrlFallbackHandler.handleFallbackIfNeeded(error: .connectionFailed)
Expand Down

0 comments on commit 590394c

Please sign in to comment.