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

Properly handle cancelled-by-user response in HttpSource #388

Closed
wants to merge 4 commits into from

Conversation

alpaix
Copy link
Contributor

@alpaix alpaix commented Mar 17, 2016

VS credential dialog throws OperationCanceledException when user hits cancel.
Added special catch to reset authentication state of HttpSource retry loop.
After the change "cancelled" source will be blocked for following authentication attempts.

//cc @yishaigalatzer @emgarten @deepakaravindr

@emgarten
Copy link
Member

This looks like a good fix.

Is there any reason the UI prompt doesn't handle this exception itself?
I like the idea of stopping after a cancel, maybe the httpsource should noop on http calls also when this is maxed and unsuccessful? All sources would keep calling it regardless, right?


// null means cancelled by user
// block subsequent attempts to annoy user with prompts
_authRetries = HttpHandlerResourceV3Provider.MaxAuthRetries;
Copy link

Choose a reason for hiding this comment

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

Why is _authRetries a global field of for this source, instead of a counter just for the current request?

Copy link
Member

Choose a reason for hiding this comment

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

During an install this would end up coming up constantly. For different UI actions it may make sense to retry for each. Do you have a specific scenario where a user might be unable to provide credentials and have to continue on but later have the correct password?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The motivation behind the fix was addressing a regression from 3.3:

  • 3 retries of credential prompts when user hits cancel
  • Failing to authenticate means restarting visual studio, given that vsts plans to deprecate credentials rather fast, I don’t think that is acceptable

VS credential dialog throws OperationCanceledException when user hits cancel.
Added special catch to reset authentication state of HttpSource retry loop.
After the change "cancelled" source will be blocked for following authentication attempts.
The purpose of this change is to scope source authentication state to an
abstract activity.

- Introduced an ambient context class with a single property
  'CorrelationId' identifying current activity
- HttpSource makes use of the CorrelationId by mapping it to a
  AuthenticationState, e.g. retries counter, blocking state.
- Added a call to create new activity in key places such as install
  package, uninstall package, restore missing packages, start search
@alpaix
Copy link
Contributor Author

alpaix commented Mar 18, 2016

//ping @rrelyea @emgarten @deepakaravindr @joelverhagen
Please take a look as I addressed "eternal source block" issue.

@alpaix
Copy link
Contributor Author

alpaix commented Mar 18, 2016

Filed a NuGet/Home#2362 describing the actual problem as reported in email.

@joelverhagen
Copy link
Member

What's the status here?

@alpaix
Copy link
Contributor Author

alpaix commented Apr 13, 2016

@joelverhagen The fix wasn't approved for 3.4.xxx release. As these milestones are all behind us I'm going to merge it to dev only.

BTW, any feedback on the fix itself?

/// <summary>
/// Represents activity unique ID.
/// </summary>
public string CorrelationId { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

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

Why a string? Guid is smaller :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

String is generic universal representation of id that can be anything. I didn't want to limit it to a specific type. Memory footprint difference is not significant here.

@joelverhagen
Copy link
Member

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.

6 participants