Skip to content

Commit 9449023

Browse files
Merge pull request #1567 from mobile-bungalow/shutdown_idempotency
Do not throw error on idempotent calls to `Socket::shutdown`
2 parents e63af86 + c781025 commit 9449023

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/LiveViewNative/Coordinators/LiveSessionCoordinator.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public class LiveSessionCoordinator<R: RootRegistry>: ObservableObject {
112112
$navigationPath.scan(([LiveNavigationEntry<R>](), [LiveNavigationEntry<R>]()), { ($0.1, $1) }).sink { [weak self] prev, next in
113113
guard let self else { return }
114114
Task {
115-
try await prev.last?.coordinator.disconnect()
115+
try? await prev.last?.coordinator.disconnect()
116116
if prev.count > next.count {
117117
let targetEntry = self.liveSocket!.getEntries()[next.count - 1]
118118
next.last?.coordinator.join(
@@ -213,7 +213,7 @@ public class LiveSessionCoordinator<R: RootRegistry>: ObservableObject {
213213
.merging(additionalHeaders ?? [:]) { $1 }
214214

215215
if let socket {
216-
try await socket.shutdown()
216+
try? await socket.shutdown()
217217
}
218218

219219
let adapter = ReconnectStrategyAdapter(self.configuration.reconnectBehavior)
@@ -336,7 +336,7 @@ public class LiveSessionCoordinator<R: RootRegistry>: ObservableObject {
336336
private func disconnect(preserveNavigationPath: Bool = false) async {
337337
do {
338338
for entry in self.navigationPath {
339-
try await entry.coordinator.disconnect()
339+
try? await entry.coordinator.disconnect()
340340
if !preserveNavigationPath {
341341
entry.coordinator.document = nil
342342
}
@@ -360,7 +360,7 @@ public class LiveSessionCoordinator<R: RootRegistry>: ObservableObject {
360360

361361
self.liveReloadChannel = nil
362362

363-
try await self.socket?.shutdown()
363+
try? await self.socket?.shutdown()
364364
self.socket = nil
365365
self.liveSocket = nil
366366
self.state = .disconnected

0 commit comments

Comments
 (0)