-
Notifications
You must be signed in to change notification settings - Fork 676
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
Debugging Unit Test loses codelens Run Test / Debug Test - DebugSessionManager does not stop #2398
Comments
More food for thought. When I kill the debug process with the Stop action it sometimes hangs as well as it must not be gracefully closing the TestServer() as it does in the fixtures dispose now.
|
It seems to be sporadic at not related to changes i have made, it appears to be timing based and some of the changes affected the timing which made it falsely appear to have worked. On my laptop (slower machine) no matter what i try, it will NOT end the debug session and i cannot debug again until a window reload is performed. Visual Studio Enterprise works just fine. I have hundreds of tests and have not seen this issue until the upgrade to the latest dotnet 2.1.301 version. If i find anything else i will share, i hope a solution will present itself soon... |
Narrowed it down to this in the start of my fixture. It doesn't like starting a new server in another thread. If i just strip my code to start like the sample below and do not call this.ServerMainReal.StopAsync() in the fixture dispose omnisharp will not end the debug process. If i do call the StopAsync() the omnisharp debug will get the command to stop the debugger. This doesn't work if say i have a break point and click stop in the debugger toolbar - i had this problem for a long time whereas i debug a unit test and have a syntax error, i would always have to reload the window in vs code. Now i know it's related to this code. I'm trying to see if i can not use real servers but the issue is that these servers have api's that use an identity server for token authorization that rely on real endpoints which is why i cannot use the TestServer object. Any suggestions/ideas would be greatly appreciated. Using a VS Enterprise is not a pleasant option for me...
|
I have the same issue in VS Code. In addition to all the other comments here I found this output in the omnisharp log: |
More interesting information, the issue appears to be linked with running visual studio 2017 enterprise (version info below). I was running fine this morning and then all of sudden i could not re-debug the unit tests (original issue), after an hour or so of troubleshooting it turns out when vs enterprise is running the debug session will not get ended in vs code. Only the integration tests that are starting the TestServer are impacted. I reproduced multiple times, debug an integration test multiple times with VS Enterprise closed and all is fine, launch VSE and debug unit test and OmniSharp.DotNetTest.DebugSessionManager never says Debug session ended. after test is done running. Microsoft Visual Studio Enterprise 2017 Installed Version: Enterprise Application Insights Tools for Visual Studio Package 8.12.10405.1 ASP.NET and Web Tools 2017 15.0.40601.0 ASP.NET Core Razor Language Services 15.7.31476 ASP.NET Web Frameworks and Tools 2017 5.2.60419.0 Azure App Service Tools v3.0.0 15.0.40608.0 Azure Data Lake Node 1.0 Azure Data Lake Tools for Visual Studio 2.3.3000.2 Azure Functions and Web Jobs Tools 15.0.40608.0 Azure Stream Analytics Tools for Visual Studio 2.3.3000.2 C# Tools 2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969 Common Azure Tools 1.10 Fabric.DiagnosticEvents 1.0 JavaScript Language Service 2.0 Microsoft Azure HDInsight Azure Node 2.3.3000.2 Microsoft Azure Hive Query Language Service 2.3.3000.2 Microsoft Azure Service Fabric Tools for Visual Studio 2.2 Microsoft Azure Stream Analytics Language Service 2.3.3000.2 Microsoft Azure Stream Analytics Node 1.0 Microsoft Azure Tools 2.9 Microsoft Continuous Delivery Tools for Visual Studio 0.3 Microsoft JVM Debugger 1.0 Microsoft MI-Based Debugger 1.0 Microsoft Visual Studio Tools for Containers 1.1 NuGet Package Manager 4.6.0 ProjectServicesPackage Extension 1.0 ResourcePackage Extension 1.0 SonarLint for Visual Studio 4.1.0.3539 SQL Server Data Tools 15.1.61804.210 ToolWindowHostedEditor 1.0 TypeScript Tools 15.7.20419.2003 Visual Basic Tools 2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969 Visual F# Tools 10.1 for F# 4.1 15.7.0.0. Commit Hash: 173513e369ffb7a1c4d5dccf83696d9aac2ab2d0. Visual Studio Code Debug Adapter Host Package 1.0 |
FYI, the reason I use VSE as part of my daily routine is for code coverage and it's nice test runner. |
I cannot confirm. I'm experiencing this issue on a Mac having no VSE installed/running. |
I am getting this issue with VS Code on a Mac too. |
@akshita31 : Do you have any thoughts here? It seems like something we could address. |
@DustinCampbell I made a fix to omnisharp-roslyn that handles a problem with the debug session : OmniSharp/omnisharp-roslyn#1239. I believe this issue should be fixed by that. @xcellsoft Can you try installing the latest beta by following these instructions and checking if the error still reproduces ? |
I just tried with the latest beta and it did not fixed it for me. Let me know if there is any info or test I could run that could help. |
@vhetet Can you provide some more repro steps. |
@akshita31 So I run or debug a test and it will work fine the first time. But after the test end I see this in the omnisharp log. The steps are basically run a unit test, and check the omnisharp log for the above error. Keep running the test until you see it. Notes: It may be necessary to run/debug a few time before it crashes Here is the my dotnet environment info Runtime Environment: Host (useful for support): .NET Core SDKs installed: .NET Core runtimes installed: To install additional .NET Core runtimes or SDKs: Let me know if there is any other info that could be useful. |
@akshita31 have you been able to look at that? It keep crashing and I have to restart VSCode every time. It's really a pain. Thanks |
Sorry, I haven't been monitoring this thread lately. I did apply the beta awhile back which helped with some issues like the syntax error problem where you'd have to restart VSCode. But it seemed to cause more frequent sporadic issues i removed the beta. There are still some issues relating to this original thread. A few times a day at least i'll start a unit test debug and it'll it just hang there and i'll have to restart vscode. In some cases i'll get the double, tripple, etc... debuggers starting which also requires a restart. I run into this quite a bit as i have 1000+ tests in my code base... If I encounter a reproducible scenario again i will post. |
@DustinCampbell I'm pretty sure the issue here is that running the test host under the debugger causes it to send bad/unexpected messages to OmniSharp, which then crashes. Note that this only happens when OmniSharp is running under mono. I've been having trouble getting the VS Code mono debugger to break on exceptions. Do you have any debugging strategies you would recommend? |
It's tough getting it reproducible on demand. I'll keep working on it - really busy on a big project. With the beta build I'm having a common issue a couple times a day. Just had it now. I feel i have less issues with the non-beta version. The syntax error bug with the unit tests appears to be fixed so it's a trade off now. Was debugging a unit test to see the outcome of some variables being populated and then I just stopped it with the debug toolbar, now all the intellisense is disabled and i cannot click F12 to go to class definitions (i can only get back intellisense on reboot, this seems a common issue with the beta). The progress indicator is showing on the editor: ...and the omnisharp log shows whereas there is no "Debug session ended":
|
@DustinCampbell Can you help us here: #2398 (comment). There are similar issues that are getting a lot of traction : #2106 |
Same issue here on my mac.
C# Extension 1.16.0
Note that restarting OmniSharp does not help here. You need to actually restart VS Code. @rchande @akshita31 Want me to come up with a repro project? Edit: This is my package references.
|
Okay, I have tested this with the simplest project possible.
My test class looks like this
Repro step(s) Hit Debug Test (code lens) once. |
FYI Did a complete uninstall/install which seem to have fixed the issue. https://stackoverflow.com/questions/42603103/how-to-completely-uninstall-vscode-on-mac |
Tried the "trick" of @seesharper to do a complete uninstall on Linux (ubuntu 18.04-x64, dotnet-sdk: 2.1.402, VSCode 1.27.2, Omnisharp-vscode 1.16.1) but this did not solve the issue. The extension still crashes on completion of the unit-test with the log-line:
As a result of the crash the complete Omnisharp feature is no longer available in VSCode. Also restarting Omnisharp or selecting the solution again does not restore the Omnisharp experience. Only a full restart of VSCode does the trick - which is more than just annoying. Also tried the latest beta (v1.17.0-beta2) but this only helps for the mono/BOM issue resulting in the red-flame. Just tried: the described behavior is not present in Windows where one can happily debug a test. |
@akshita31 I'll try that later today. I'll keep you updated. |
I updated the version of mono to 5.16 but it's still failing. Sorry for the delay I meant to do it earlier. |
@akshita31 @rchande I noticed this from the OmniSharp log
|
@vhetet what kind of project is this that you're having trouble with? |
@seesharper It's also in for a web api project. But it does it for all the unit tests so I don't think it's related to controllers method specifically. |
No, but it could be related somehow. In the web api test project all tests causes Omnisharp to die. Have another project where everything is fine |
@vhetet, @akshita31 , @rchande Can you try with this project ? It is the simplest thing I could do. Once I debug that one test, OmniSharp dies dotnet --info
|
I discovered something that might be useful. In the repro project https://github.com/seesharper/Omnisharp-WebApi If I run the test with the solution loaded, meaning both the test project and the webapi project, the test causes death to OmniSharp. Note that the test project does not even reference the web api project. Now, If I open ONLY the test project, the test runs fine in debug mode. So maybe it is related to what assemblies are being fed into the debugger or something in that direction? When I think about this, the problem has been mostly prominent on project involving AspNetCore UPDATE. I managed to get it to fail even when loading just the test project, but I had to run the test(debug) like 20 times for it to fail. Could it be a memory thing? Or simply a timing issue somewhere? |
I tried why your repro project and it fails for me too |
I am having the same issue, trying to debug and the lens disappears
|
Another +1 to fix this issue.
|
@rchande Any updates on this? |
Just stop the debugger when unhandled exception is thrown will solve the problem. Just don't "continue" the debugger. |
FYI, I'll second this issue. I even tried reinstalling VS code in no vail. Codelens comes back when I restart VS code. Not a very complex project either ... Its code can be found here (add the magic.io submodule following the recipe) in case you'd like to reproduce it ... |
I am getting the exact same error.
I am running an extension in VS Code called Remote Development. It is an extension pack that installs, "Remote - Containers". This enables me to develop within a Docker container, regardless of host OS. Host:
|
Still exists as an issue for me as well. |
Also experiencing this error: macOS Mojave 10.14.6 dotnetcore 3.1 Debug tests once then omnisharp is killed. Successfully loaded project file '/app/service/WebAPIApplication.csproj'. |
Yeah I'm having the same issue on Windows developing in WSL1.
Only restarting VS fixes it. Windows InfoOS : Windows 10 Pro WSL InfoOS : Ubuntu 20.04 LTS VS Code InfoVersion: 1.48.0-insider (user setup) |
Same issue here on Ubuntu 20.04
|
ubuntu 20, vscode 1.60, dotnet 5. As I posted on a related issue: I can often (but not always) prevent a crash by disabling the "All Exceptions" and "User-Unhandled Exceptions" breakpoints. When those are disabled, it crashes less often. When those are enabled - and I hit a breakpoint, or step through code - and step over a throw new FooException(), it'll proceed to the end of the test, then crash (a Mono crash like described above.) |
Unfortunatelly, I've test it right now it doesn't works for me. Please OmniSharp team help to us this issue that means restart VS Code after every fail in UNIT testig ... |
Some feedback: since upgrading to the net6-based o#, I no longer have debugging crashes. 😄 |
I'm still experiencing this issue, VS Code 1.73.1. I have to restart my computer to get the run test/debug test options to show! |
Related to #1743
Environment data
dotnet --info
output:.NET Core SDK (reflecting any global.json):
Version: 2.1.301
Commit: 59524873d6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.301\
Host (useful for support):
Version: 2.1.1
Commit: 6985b9f684
.NET Core SDKs installed:
1.0.4 [C:\Program Files\dotnet\sdk]
2.0.2 [C:\Program Files\dotnet\sdk]
2.0.3 [C:\Program Files\dotnet\sdk]
2.1.2 [C:\Program Files\dotnet\sdk]
2.1.3 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.100 [C:\Program Files\dotnet\sdk]
2.1.101 [C:\Program Files\dotnet\sdk]
2.1.102 [C:\Program Files\dotnet\sdk]
2.1.103 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.105 [C:\Program Files\dotnet\sdk]
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.301 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
PS D:\CBRock\XCellorator>
VS Code version: 1.24.1
C# Extension version:
ms-vscode.csharp-1.15.2.omnisharp\1.30.1\OmniSharp.exe
Steps to reproduce
Create a TestServer that has a IHostedService with dependencies and do not perform a graceful close on the TestServer using the following code:
this.testServerIam.Host.StopAsync().GetAwaiter().GetResult();
. TheOmniSharp.DotNetTest.DebugSessionManager
will never report "Debug session ended", it will be stuck with "Debug session started.", even though the .NET Test Log says Debugging complete. The extra host process not being cleaned up / shutdown must be confusing omnisharp. In some cases the codelens may appear on a fresh restart but clicking the debug again will just hang with the debug starting in the output window (it will never start).Expected behavior
Omnisharp debug session stops, codelens run/debug appears and a subsequent debug can be performed.
The text was updated successfully, but these errors were encountered: