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

Team Explorer and GitHub pane show the wrong repository #1493

Closed
shana opened this Issue Feb 15, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@shana
Collaborator

shana commented Feb 15, 2018

Steps to repro:

  • Pin VS to the windows taskbar
  • Open VS
  • Open a solution in repository A
  • Open a solution in repository B
  • Close VS
  • Right click on the VS icon in the taskbar and select solution in Repository A

Expected: GHfVS displays the information of Repository A in Team Explorer Home and GitHub pane
Actual: GHfVS displays the information of Repository B in Team Explorer Home and GitHub pane

This is likely a regression after 2.3.6.391

Screenshots of issue:
image 1

image

Gif of issue:
switching-repos-bug

@meaghanlewis

This comment has been minimized.

Contributor

meaghanlewis commented Feb 15, 2018

Error from log file:

Octokit.NotFoundException: Not Found
   at Octokit.Connection.HandleErrors(IResponse response) in C:\projects\visualstudio\submodules\octokit.net\Octokit\Http\Connection.cs:line 607
   at Octokit.Connection.<RunRequest>d__55.MoveNext() in C:\projects\visualstudio\submodules\octokit.net\Octokit\Http\Connection.cs:line 588
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Octokit.Connection.<Run>d__54`1.MoveNext() in C:\projects\visualstudio\submodules\octokit.net\Octokit\Http\Connection.cs:line 573
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Octokit.ApiConnection.<Get>d__8`1.MoveNext() in C:\projects\visualstudio\submodules\octokit.net\Octokit\Http\ApiConnection.cs:line 0
--- End of stack trace from previous location where exception was thrown ---
   at System.Reactive.PlatformServices.ExceptionServicesImpl.Rethrow(Exception exception)
   at System.Reactive.ExceptionHelpers.ThrowIfNotNull(Exception exception)
   at System.Reactive.Subjects.AsyncSubject`1.GetResult()
   at GitHub.InlineReviews.Services.PullRequestSessionManager.<StatusChanged>d__19.MoveNext() in C:\projects\visualstudio\src\GitHub.InlineReviews\Services\PullRequestSessionManager.cs:line 224
{"message":"Not Found","documentation_url":"https://developer.github.com/v3/pulls/#get-a-single-pull-request"}
2018-02-15 10:26:34.600 INFO [01] GitHubPackage             Initializing GitHub Extension v2.4.2.1331 in Microsoft Visual Studio 2015 (14.0.25420.1)
2018-02-15 10:26:58.338 EROR [01] PullRequestSessionManager Error changing repository
System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.
   at System.Threading.Tasks.TaskCompletionSource`1.SetResult(TResult result)
   at GitHub.InlineReviews.Services.PullRequestSessionManager.<StatusChanged>d__19.MoveNext() in C:\projects\visualstudio\src\GitHub.InlineReviews```

grokys added a commit that referenced this issue Feb 16, 2018

@grokys

This comment has been minimized.

Contributor

grokys commented Feb 16, 2018

On https://github.com/github/VisualStudio/tree/fixes/1493-wrong-repo I added some logging. I then created two shortcuts to run the experimental instance: one to open github/VisualStudio and one to open haacked/Rothko.

Clicking on the first shortcut (github/VisualStudio) followed by the second (haacked/Rothko) reproduced the bug. Here is the log produced:

2018-02-16 15:48:33.059 INFO [01] GitHubPackage             Initializing GitHub Extension v2.4.3.0 in Microsoft Visual Studio 2015 (14.0.25420.1)
2018-02-16 15:48:34.486 DBUG [01] VSGitExt                  ActiveRepositories changed to []
2018-02-16 15:48:34.488 DBUG [01] VSGitExt                  Found IGitExt service and initialized VSGitExt
2018-02-16 15:48:34.492 DBUG [17] VSGitExt                  IGitExt.ActiveRepositories (#43546682) returned ["C:\\Users\\grokys\\Source\\Repos\\VisualStudio"]
2018-02-16 15:48:34.965 DBUG [15] VSGitExt                  IGitExt.ActiveRepositories (#43546682) returned ["D:\\projects\\Rothko"]
2018-02-16 15:48:37.004 DBUG [15] VSGitExt                  ActiveRepositories changed to ["https://github.com/editor-tools/Rothko"]
2018-02-16 15:48:37.004 DBUG [17] VSGitExt                  ActiveRepositories changed to ["https://github.com/github/VisualStudio"]
2018-02-16 15:48:37.389 DBUG [15] TeamExplorerContext       ActiveRepository changed to https://github.com/editor-tools/Rothko @ D:\projects\Rothko
2018-02-16 15:48:37.391 DBUG [17] TeamExplorerContext       ActiveRepository changed to https://github.com/github/VisualStudio @ C:\Users\grokys\Source\Repos\VisualStudio

You can see that IGitExt fires with the change notifications in the correct order, but on different threads. By the time VSGitExt.ActiveRepositories is set, these two notifications are out of order.

@shana

This comment has been minimized.

Collaborator

shana commented Feb 16, 2018

Nice spelunking there, good work!

grokys added a commit that referenced this issue Feb 20, 2018

Added failing test for #1493.
Unfortunately it will only fail on some runs. Seems that if it gets past the first iteration, it will always pass...

grokys added a commit that referenced this issue Feb 20, 2018

grokys added a commit that referenced this issue Feb 20, 2018

Lock VSGitExt.RefreshActiveRepositories
Wait on a lock in `VSGitExt.RefreshActiveRepositories` so that `ActiveRepositoriesChanged` notifications are raised in the correct order.

Fixes #1493

@meaghanlewis meaghanlewis added this to In Progress in BUGS Feb 20, 2018

BUGS automation moved this from In Progress to Done Feb 21, 2018

@meaghanlewis meaghanlewis removed this from Done in BUGS Mar 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment