Skip to content

Commit 8b321a0

Browse files
Update
1 parent c277d73 commit 8b321a0

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Libraries/Connect/Public/Implementation/Clients/URLSessionHTTPClient.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,20 @@ open class URLSessionHTTPClient: NSObject, HTTPClientInterface, @unchecked Senda
114114
self.metricsClosures[urlSessionStream.taskID] = responseCallbacks.receiveResponseMetrics
115115
}
116116
return RequestCallbacks(
117-
cancel: { urlSessionStream.cancel() },
118-
sendData: { data in
117+
cancel: { [weak urlSessionStream] in urlSessionStream?.cancel() },
118+
sendData: { [weak urlSessionStream] data in
119119
do {
120-
try urlSessionStream.sendData(data)
120+
try urlSessionStream?.sendData(data)
121121
} catch let error {
122122
os_log(
123123
.error,
124124
"Failed to write data to stream - closing connection: %@",
125125
error.localizedDescription
126126
)
127-
urlSessionStream.close()
127+
urlSessionStream?.close()
128128
}
129129
},
130-
sendClose: { urlSessionStream.close() }
130+
sendClose: { [weak urlSessionStream] in urlSessionStream?.close() }
131131
)
132132
}
133133

0 commit comments

Comments
 (0)