Conversation
Fix multiple NWConnection during migrateConnection
|
Problem: Solution |
| private func migrateConnection(completionHandler: @escaping (Result<WebSocketConnection, NWError>) -> Void) { | ||
|
|
||
| let migratedConnection = NWConnection(to: endpoint, using: parameters) | ||
| migratedConnection?.cancel() |
There was a problem hiding this comment.
if migrateConnection was already called and successfully ended, in the next call when you cancelling migratedConnection you cancelling current 'connection'
|
Thanks for raising this @ajinumoto. The issue of multiple guard !isMigratingConnection else {
completionHandler(.failure(NWError.posix(.EALREADY)))
return
}The same PR also introduced explicit cleanup of the old connection's handlers before cancelling it with a short delay, ensuring no stale callbacks fire during the transition. Closing this in favour of that work. If you're still able to reproduce the issue on the latest release (0.5.10), please open a new issue and we'll take another look. |
Fix multiple NWConnection during migrateConnection