Skip to content

Commit 23176d6

Browse files
committed
fix: move [weak self] capture into inner Task closures
Swift 5.10 strict concurrency rejects capturing the outer closure's weak `self` (a `var`) into an inner `Task` closure that only later unwraps it via `guard let self`. Pull `[weak self]` directly onto the inner Task closure so the capture happens in the concurrent boundary itself instead of crossing through an outer mutable binding. Affects TunnelManager IPC stop observer and LogsWindow termination handler.
1 parent 9f789df commit 23176d6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Sources/CloudTunnels/Core/TunnelManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ final class TunnelManager: ObservableObject {
4242

4343
// Listen for `ctun stop <name>` requests so we disconnect the same
4444
// tunnel cleanly (no auto-reconnect race) when the CLI asks for it.
45-
self.stopRequestObserver = IPCNotifications.observeStopRequest { [weak self] id in
46-
Task { @MainActor in
45+
self.stopRequestObserver = IPCNotifications.observeStopRequest { id in
46+
Task { @MainActor [weak self] in
4747
guard let self else { return }
4848
if self.tunnels.contains(where: { $0.id == id }) {
4949
self.log.info("ipc stop request received for \(id.uuidString, privacy: .public)")

Sources/CloudTunnels/UI/LogsWindow.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ final class LogStreamer: ObservableObject {
9292
}
9393
}
9494

95-
proc.terminationHandler = { [weak self] terminated in
96-
Task { @MainActor in
95+
proc.terminationHandler = { terminated in
96+
Task { @MainActor [weak self] in
9797
guard let self else { return }
9898
self.isRunning = false
9999
self.process = nil

0 commit comments

Comments
 (0)