fix: temporarily disable vpn toggle after toggling off #43
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.
There appears to be a race between the VPN service reporting itself as disconnected, and the system extension process exiting. When the VPN is toggled off and on quickly, an error is shown:
This PR forces the user to wait 6 seconds before they can toggle the VPN back on.
6 seconds was chosen as on my machine it takes about that long for the app to log that the XPC connection was interrupted after the
stopTunnel
function returns, and the system informs the app the VPN has been disconnected.The XPC connection in the network extension is in the global scope, so it makes sense for it's death to imply the process has finally exited.
Potentially related:
![image](https://private-user-images.githubusercontent.com/39577870/413184442-ad0209b0-d2e4-4402-8be4-4b419d4b8d0e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MjIxNjcsIm5iZiI6MTczOTYyMTg2NywicGF0aCI6Ii8zOTU3Nzg3MC80MTMxODQ0NDItYWQwMjA5YjAtZDJlNC00NDAyLThiZTQtNGI0MTlkNGI4ZDBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDEyMTc0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUzOWRjMWRlYzJiMmYzOTdjZGUxYmQ1YzNlYTM2YjVkNWMzODlmYTg0YmEwMjk2MDE2NGIyNjFmZmNiYTYzZDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ZYY5eHXsdbFc4JUBfsyKbQYi7mQIS-Wf19C3geohJg8)
https://developer.apple.com/forums/thread/84920?answerId=252931022#252931022