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

Fix notification handler tests to use per server task completion instances #72963

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Apr 9, 2024

Reproduced locally using multiple iterations. Issue was the static task completion source was being re-used across multiple server instances, causing the test to exit too early after a previous test completed.

Fixes failures like https://dnceng-public.visualstudio.com/public/_build/results?buildId=636591&view=ms.vss-test-web.build-test-results-tab&runId=15674606&resultId=230727&paneView=dotnet-dnceng.dnceng-anon-build-release-tasks.helix-anon-test-information-tab

[06:38:20.827][Info]Using C# from request text document
 [06:38:20.827][Info]Shutting down
 [06:38:20.827][Error]Could not find appropriate workspace or solution on NotificationHandler
 [06:38:20.827][Start]NotificationHandler
 [06:38:20.827][Warning]
 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 Microsoft.CodeAnalysis.LanguageServer.UnitTests.HandlerTests.NotificationHandler.HandleNotificationAsync(TestRequestTypeOne request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/ProtocolUnitTests/HandlerTests.cs:line 200
    at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.<StartRequestAsync>d__20.MoveNext() in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 162
 [06:38:20.827][End]NotificationHandler

@dibarbet dibarbet requested a review from a team as a code owner April 9, 2024 22:46
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 9, 2024
Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

signing off as this is all test-only changes.

@CyrusNajmabadi
Copy link
Member

Dumb question, why do we have the test handlers here instead of tewstnig the real handler?

@dibarbet
Copy link
Member Author

Dumb question, why do we have the test handlers here instead of tewstnig the real handler?

A few reasons

  1. So the test can wait and verify that a notification handler is actually called (requires the task completion source stuff inside the handler here since the caller's task completes before the handler is executed).
  2. Isolation against changes - these are intentionally testing that certain shapes of the handlers work (for example notifications without params, notifications with params). Avoids issues where the real handler might add/remove parameters for whatever reason.
  3. I don't think we actually have a real parameterless notification handler (but if we, or a consumer ever wants to add one, it needs to work).

@dibarbet dibarbet merged commit beea736 into dotnet:main Apr 10, 2024
25 of 27 checks passed
@dibarbet dibarbet deleted the fix_handler_test branch April 10, 2024 18:13
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 10, 2024
@dibarbet dibarbet modified the milestones: Next, 17.11 P1 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants