File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,10 @@ open class Session: ObservableObject {
132132 receivers: receivers)
133133 }
134134
135+ deinit {
136+ waitForAgentTask? . cancel ( )
137+ }
138+
135139 private func observe( room: Room ) {
136140 Task { [ weak self] in
137141 for try await _ in room. changes {
@@ -192,9 +196,10 @@ open class Session: ObservableObject {
192196 let timeout = options. agentConnectTimeout
193197
194198 defer {
195- waitForAgentTask = Task {
199+ waitForAgentTask = Task { [ weak self ] in
196200 try await Task . sleep ( nanoseconds: UInt64 ( timeout * Double( NSEC_PER_SEC) ) )
197201 try Task . checkCancellation ( )
202+ guard let self else { return }
198203 if connectionState == . connected, agents. isEmpty {
199204 self . error = . agentNotConnected
200205 }
You can’t perform that action at this time.
0 commit comments