Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPN can't be reconnected in the same session when internet/wifi is disabled #13867

Merged
merged 2 commits into from
Jun 24, 2022

Conversation

spylogsster
Copy link
Contributor

@spylogsster spylogsster commented Jun 20, 2022

Resolves brave/brave-browser#23081

There are 2 different issues:

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@spylogsster spylogsster self-assigned this Jun 20, 2022
@github-actions github-actions bot added the CI/storybook-url Deploy storybook and provide a unique URL for each build label Jun 20, 2022
@spylogsster spylogsster force-pushed the brave-23081 branch 2 times, most recently from 1249cd0 to 9255ae1 Compare June 20, 2022 11:41
@spylogsster spylogsster removed the CI/storybook-url Deploy storybook and provide a unique URL for each build label Jun 20, 2022
@spylogsster spylogsster requested a review from bsclifton June 20, 2022 12:25
@spylogsster spylogsster changed the title wip: VPN can't be reconnected in the same session when internet/wifi is di… VPN can't be reconnected in the same session when internet/wifi is disabled Jun 20, 2022
@spylogsster spylogsster marked this pull request as ready for review June 20, 2022 12:25
@spylogsster spylogsster added this to the 1.42.x - Nightly milestone Jun 20, 2022
@spylogsster spylogsster force-pushed the brave-23081 branch 3 times, most recently from 73df7e2 to d57028f Compare June 22, 2022 09:09
@bsclifton bsclifton requested a review from simonhong June 23, 2022 08:03
@@ -1015,6 +1016,12 @@ void BraveVpnService::OnPrepareCredentialsPresentation(
FetchRegionData(false);
}

if (!IsNetworkAvailable()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why connect failed setting is needed here?
Do you want to set it If we have network failure during the loading purchased state?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and do you think purchased state also should be changed to (failed?) when network failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a call form the panel to get credentials. Since the credentials are stored in prefs it goes here and trying to connect which takes some time and user sees loading throbber for some time. Probably better idea to put it into GetBraveVPNConnectionAPI()->CheckConnection wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it to LoadPurchasedState as discussed in Slack

@@ -900,6 +901,12 @@ void BraveVpnService::LoadPurchasedState() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (GetPurchasedStateSync() == PurchasedState::LOADING)
return;
if (!IsNetworkAvailable()) {
VLOG(2) << __func__ << ": Network is not available, failed to connect";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: failed to check purchased state?

Copy link
Contributor Author

@spylogsster spylogsster Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping connect as discussed in Slack

if (!IsNetworkAvailable()) {
VLOG(2) << __func__ << ": Network is not available, failed to connect";
SetPurchasedState(PurchasedState::NOT_PURCHASED);
UpdateAndNotifyConnectionStateChange(ConnectionState::CONNECT_FAILED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to notify this by monitoring network state instead of doing here. Is it possible?

Copy link
Contributor Author

@spylogsster spylogsster Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we call this from typescript when open the panel and wait for long timeout

@spylogsster spylogsster force-pushed the brave-23081 branch 4 times, most recently from 6961d2a to f56d423 Compare June 23, 2022 12:38
simonhong
simonhong previously approved these changes Jun 23, 2022
components/brave_vpn/brave_vpn_service.cc Outdated Show resolved Hide resolved
@spylogsster spylogsster force-pushed the brave-23081 branch 2 times, most recently from 2f0f372 to 2c68cd2 Compare June 24, 2022 05:07
simonhong
simonhong previously approved these changes Jun 24, 2022
@spylogsster spylogsster merged commit fdfc0c9 into master Jun 24, 2022
@spylogsster spylogsster deleted the brave-23081 branch June 24, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VPN can't be reconnected in the same session when internet/wifi is disconnected and reconnected
2 participants