Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the pull request
Enhanced the migrate connection code to resolve issues with
NWConnection
leaks. Additionally, implemented validation measures to avert the occurrence of reconnection loops.Why is the change necessary?
Certain modifications have been implemented to address memory leaks during the execution of the
migrateConnection
function. However, the key alteration revolves around cases where theNWConnection
instance on iOS is unexpectedly disposed of. In such instances, regardless of the number of reconnection attempts, they are destined to fail due to the connection's disposal. To counteract this situation, a safeguard has been introduced to detect entry into this reconnection loop. Consequently, the connection is deliberately dismantled, paving the way for the establishment of a freshNWConnection
instance, enabling subsequent reconnection attempts to succeed.