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

authentication.getSession can return 'stuck' authentication requests #211406

Closed
peterbom opened this issue Apr 26, 2024 · 3 comments · Fixed by #211495
Closed

authentication.getSession can return 'stuck' authentication requests #211406

peterbom opened this issue Apr 26, 2024 · 3 comments · Fixed by #211495
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders microsoft-authentication Issues with the Microsoft Authentication extension verified Verification succeeded
Milestone

Comments

@peterbom
Copy link

Does this issue occur when all extensions are disabled?: Yes/No
Technically no, but that's because you need an extension to call the VS Code API.

  • VS Code Version: 1.88.1
  • OS Version: Windows_NT x64 10.0.22631

Steps to Reproduce:

  1. Invoke code which calls authentication.getSession() with createIfNone: true and silent: false
  2. Accept the confirmation dialog and allow a browser tab to appear
  3. Close the browser tab without completing the interactive authentication
  4. Invoke code which calls authentication.getSession() with the same scopes and options as before

The last step will hang indefinitely, with no exception thrown. It can be observed in the Azure Resources extension, but is not limited to that extension.

I believe this is similar to this issue/feature request.

What seems to be happening (thanks to @TylerLeonhardt for helping confirm this) is that VS Code has no way of detecting if the user has closed the browser tab, and so it cannot throw an error when this happens. There might be a timeout, but if there is, it is very long and users will be left wondering what has happened.

It is possible for extensions to implement cancellation themselves, which would just abandon the getSession call and allow users to invoke it again. But this doesn't work, because getSession caches its requests and returns an existing promise, which in this case is blocked indefinitely. Thus, users cannot log in until they reload the window or restart VS Code.

@TylerLeonhardt
Copy link
Member

With the PR above, the user will now see:
image

this is what we use for GitHub auth as well so it's a fairly common pattern.

@TylerLeonhardt TylerLeonhardt added bug Issue identified by VS Code Team member as probable bug microsoft-authentication Issues with the Microsoft Authentication extension labels Apr 26, 2024
@TylerLeonhardt TylerLeonhardt added this to the May 2024 milestone Apr 26, 2024
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Apr 26, 2024
@alexr00 alexr00 added the author-verification-requested Issues potentially verifiable by issue author label May 29, 2024
@vscodenpa
Copy link

This bug has been fixed in the latest release of VS Code Insiders!

@peterbom, you can help us out by commenting /verified if things are now working as expected.

If things still don't seem right, please ensure you're on version fc8762e of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@connor4312 connor4312 added the verified Verification succeeded label May 29, 2024
@peterbom
Copy link
Author

peterbom commented Jun 4, 2024

/verified

@vscodenpa vscodenpa removed the author-verification-requested Issues potentially verifiable by issue author label Jun 4, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders microsoft-authentication Issues with the Microsoft Authentication extension verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants