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

Debugging Unit Test loses codelens Run Test / Debug Test - DebugSessionManager does not stop #2398

Open
xcellsoft opened this issue Jun 29, 2018 · 57 comments · Fixed by #2579

Comments

@xcellsoft
Copy link

xcellsoft commented Jun 29, 2018

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();. The OmniSharp.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.

@xcellsoft
Copy link
Author

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.

            this.testServerMain = new TestServer(company.app.Main.Program
                .GetWebHostBuilder(Path.GetFullPath("../../../../../Src/company.app.Main"), args));
            testServerMain.BaseAddress = new Uri("http://acme.localhost:5003");

@xcellsoft
Copy link
Author

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...

@xcellsoft
Copy link
Author

xcellsoft commented Jun 30, 2018

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...

this.ServerMainReal = company.app.Program
                .BuildWebHost(Path.GetFullPath("../../../../../Src/company.app.Main"), argsMain);
            this.ServerMainReal.Start();

@robbash
Copy link

robbash commented Jul 2, 2018

I have the same issue in VS Code.

In addition to all the other comments here I found this output in the omnisharp log:
/Users/myuser/.vscode/extensions/ms-vscode.csharp-1.15.2/.omnisharp/1.30.1/run: line 50: 65745 Killed: 9 "${MONO_CMD}" "${OMNISHARP_CMD}" "$@"

@xcellsoft
Copy link
Author

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
Version 15.7.4
VisualStudio.15.Release/15.7.4+27703.2035
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Enterprise

Application Insights Tools for Visual Studio Package 8.12.10405.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.0.40601.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 15.7.31476
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017 5.2.60419.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 15.0.40608.0
Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.3.3000.2
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 15.0.40608.0
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.3.3000.2
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events

JavaScript Language Service 2.0
JavaScript Language Service

Microsoft Azure HDInsight Azure Node 2.3.3000.2
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.3.3000.2
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 2.2
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.3.3000.2
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10420.2

Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

SonarLint for Visual Studio 4.1.0.3539
SonarLint is an extension to your favorite IDE that provides on-the-fly feedback to developers on new bugs and quality issues injected into their code.

SQL Server Data Tools 15.1.61804.210
Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript Tools 15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.1 for F# 4.1 15.7.0.0. Commit Hash: 173513e369ffb7a1c4d5dccf83696d9aac2ab2d0.
Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

@xcellsoft
Copy link
Author

xcellsoft commented Jul 2, 2018

FYI, the reason I use VSE as part of my daily routine is for code coverage and it's nice test runner.

@robbash
Copy link

robbash commented Jul 3, 2018

More interesting information, the issue appears to be linked with running visual studio 2017 enterprise (version info below).

I cannot confirm. I'm experiencing this issue on a Mac having no VSE installed/running.

@vhetet
Copy link

vhetet commented Aug 14, 2018

I am getting this issue with VS Code on a Mac too.
Have you guys found a fix?
The only way I have is to restart VS Code.
Thanks

@DustinCampbell
Copy link
Member

@akshita31 : Do you have any thoughts here? It seems like something we could address.

@akshita31
Copy link
Contributor

@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 ?

@vhetet
Copy link

vhetet commented Aug 23, 2018

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.

@akshita31
Copy link
Contributor

akshita31 commented Aug 24, 2018

@vhetet Can you provide some more repro steps.

@vhetet
Copy link

vhetet commented Aug 24, 2018

@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.
/Users/vhetet/.vscode/extensions/ms-vscode.csharp-1.16.0-beta1/.omnisharp/1.32.2/run: line 28: 72415 Killed: 9 "${mono_cmd}" "${omnisharp_cmd}" "$@"
After that run and debug don't work and I need to restart VSCode

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
.NET Core SDK (reflecting any global.json):
Version: 2.1.301
Commit: 59524873d6

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.301/

Host (useful for support):
Version: 2.1.1
Commit: 6985b9f684

.NET Core SDKs installed:
2.1.300 [/usr/local/share/dotnet/sdk]
2.1.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Let me know if there is any other info that could be useful.

@vhetet
Copy link

vhetet commented Aug 30, 2018

@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

@xcellsoft
Copy link
Author

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.

@rchande
Copy link

rchande commented Aug 30, 2018

@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?

@xcellsoft
Copy link
Author

xcellsoft commented Aug 30, 2018

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:

image

...and the omnisharp log shows whereas there is no "Debug session ended":

[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Connected","Payload":null}
[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"ProtocolVersion","Payload":1}
[info]: OmniSharp.DotNetTest.DebugSessionManager
        Debug session started.

@akshita31
Copy link
Contributor

@DustinCampbell Can you help us here: #2398 (comment). There are similar issues that are getting a lot of traction : #2106

@akshita31 akshita31 added this to the 1.17 milestone Sep 6, 2018
@akshita31 akshita31 assigned rchande and unassigned akshita31 Sep 7, 2018
@seesharper
Copy link

seesharper commented Sep 12, 2018

Same issue here on my mac.

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.401/

Host (useful for support):
  Version: 2.1.3
  Commit:  124038c13e

.NET Core SDKs installed:
  1.1.10 [/usr/local/share/dotnet/sdk]
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.1.300-preview1-008174 [/usr/local/share/dotnet/sdk]
  2.1.300-preview2-008533 [/usr/local/share/dotnet/sdk]
  2.1.300 [/usr/local/share/dotnet/sdk]
  2.1.401 [/usr/local/share/dotnet/sdk]

C# Extension 1.16.0

  1. Run test
  2. Debug test with breakpoint for which I hit F5 to continue
  3. Code lens dies and I have to restart VS Code

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.

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
    <PackageReference Include="NSubstitute " Version="3.1.0" />
    <PackageReference Include="Shouldly" Version="3.0.0" />
    <PackageReference Include="xunit" Version="2.3.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

@seesharper
Copy link

Okay, I have tested this with the simplest project possible.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
    <PackageReference Include="xunit" Version="2.3.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
  </ItemGroup>

</Project>

My test class looks like this

using System;
using Xunit;

namespace DebugTest
{
    public class UnitTest1
    {
        [Fact]
        public void ShouldBeOk()
        {

        }
    }
}

Repro step(s)

Hit Debug Test (code lens) once.
Once that is finished, code lens is broken and no language services from OmniSharp are working.

@seesharper
Copy link

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

@bihe
Copy link

bihe commented Sep 29, 2018

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:

/home/henrik/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/run: line 28: 22949 Killed "${mono_cmd}" "${omnisharp_cmd}" "$@"

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.

@vhetet
Copy link

vhetet commented Dec 4, 2018

@akshita31 I'll try that later today. I'll keep you updated.

@vhetet
Copy link

vhetet commented Dec 6, 2018

I updated the version of mono to 5.16 but it's still failing.
I can debug a few time. But eventually it fails. Is there any info or log I could share that could help understanding the issue?

Sorry for the delay I meant to do it earlier.

@seesharper
Copy link

@akshita31 @rchande
I am sad to say that it has started failing for me again too.

I noticed this from the OmniSharp log

/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/run: line 28: 67348 Killed: 9               "${mono_cmd}" "${omnisharp_cmd}" "$@"

@seesharper
Copy link

@vhetet what kind of project is this that you're having trouble with?
For me it is really unstable when testing Web api controllers.

@vhetet
Copy link

vhetet commented Dec 11, 2018

@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.

@seesharper
Copy link

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

@seesharper
Copy link

@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
https://github.com/seesharper/Omnisharp-WebApi

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.2.100
 Commit:    51868761f2

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.2.100/

Host (useful for support):
  Version: 2.2.0
  Commit:  1249f08fed

.NET Core SDKs installed:
  1.1.10 [/usr/local/share/dotnet/sdk]
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.1.300-preview1-008174 [/usr/local/share/dotnet/sdk]
  2.1.300-preview2-008533 [/usr/local/share/dotnet/sdk]
  2.1.300 [/usr/local/share/dotnet/sdk]
  2.1.401 [/usr/local/share/dotnet/sdk]
  2.1.402 [/usr/local/share/dotnet/sdk]
  2.2.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0-preview1-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.0-preview2-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0-preview1-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.0-preview2-final [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0-preview1-26216-03 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0-preview2-26406-04 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

@seesharper
Copy link

seesharper commented Dec 11, 2018

@rchande @akshita31 @vhetet

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?

@vhetet
Copy link

vhetet commented Dec 12, 2018

I tried why your repro project and it fails for me too

@seesharper
Copy link

@vhetet If you set a breakpoint in the test and then end the debug session using to "stop" button. Does it still kill OmniSharp? For me it works as long as I set a breakpoint and hit the "stop" button.
@rchande, @filipw Thoughts about that?

@gregg-miskelly gregg-miskelly modified the milestones: 1.17, 1.18 Jan 2, 2019
@RussKie
Copy link
Member

RussKie commented Jan 25, 2019

I am having the same issue, trying to debug and the lens disappears

  • VSCode Version 1.30.2 (1.30.2), 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
  • Mono JIT compiler version 5.16.0.221 (2018-06/b63e5378e38 Mon Nov 19 18:08:09 EST 2018)
  • .NET Core SDK (reflecting any global.json):
 Version:   2.1.302
 Commit:    9048955601

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.302/

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

@bertrand-benoit
Copy link

bertrand-benoit commented Feb 1, 2019

Another +1 to fix this issue.

  • VSCode V.1.30.2
  • Mono JIT compiler version 5.18.0.225-0
  • .NET Core SDK (reflecting any global.json):
 Version:   2.2.102
 Commit:    96ff75a873

Runtime Environment:
 OS Name:     fedora
 OS Version:  26
 OS Platform: Linux
 RID:         fedora.26-x64
 Base Path:   /mnt/windows/_filesForGNULinux/dotnet/sdk/2.2.102/

Host (useful for support):
  Version: 2.2.1
  Commit:  878dd11e62

.NET Core SDKs installed:
  2.2.102 [/mnt/windows/_filesForGNULinux/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.1 [/mnt/windows/_filesForGNULinux/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.1 [/mnt/windows/_filesForGNULinux/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.1 [/mnt/windows/_filesForGNULinux/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

@seesharper
Copy link

@rchande Any updates on this?

@ethan-deng
Copy link

Just stop the debugger when unhandled exception is thrown will solve the problem. Just don't "continue" the debugger.

@polterguy
Copy link

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 ...

@djlawhead
Copy link

I am getting the exact same error.

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     debian
 OS Version:  10
 OS Platform: Linux
 RID:         debian.10-x64
 Base Path:   /usr/share/dotnet/sdk/3.0.100/

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  3.0.100 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

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:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.2.402 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@schaveyt
Copy link

Still exists as an issue for me as well.

@trackingallday
Copy link

trackingallday commented Jun 11, 2020

Also experiencing this error:

macOS Mojave 10.14.6

dotnetcore 3.1
opening project in a dev container using vs code

Debug tests once then omnisharp is killed.
Tests are in a referenced project
Tests are testing controllers

Successfully loaded project file '/app/service/WebAPIApplication.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project '/app/service/WebAPIApplication.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: Tests
info: OmniSharp.MSBuild.ProjectManager
Update project: WebAPIApplication
info: OmniSharp.DotNetTest.VSTestManager
read: {"MessageType":"TestSession.Connected","Payload":null}
info: OmniSharp.DotNetTest.VSTestManager
read: {"MessageType":"ProtocolVersion","Payload":1}
info: OmniSharp.DotNetTest.DebugSessionManager
Debug session started.
/root/.vscode-server/extensions/ms-dotnettools.csharp-1.22.0/.omnisharp/1.35.2/run: line 28: 235 Killed "${mono_cmd}" "${omnisharp_cmd}" "$@"

@wbuck
Copy link

wbuck commented Jul 10, 2020

Yeah I'm having the same issue on Windows developing in WSL1.

.vscode-server-insiders/extensions/ms-dotnettools.csharp-1.22.1/.omnisharp/1.35.3/run: line 28: 12519 Killed "${mono_cmd}" "${omnisharp_cmd}" "$@"

Only restarting VS fixes it.

Windows Info

OS : Windows 10 Pro
Version : 1909
Build : 18363.900

WSL Info

OS : Ubuntu 20.04 LTS
Release : 20.04

VS Code Info

Version: 1.48.0-insider (user setup)
Commit: e7920dce7bfd0b707ebfc0a5379c6edd2233e475
Date: 2020-07-10T11:58:37.847Z
Electron: 8.3.3
Chrome: 80.0.3987.165
Node.js: 12.13.0
V8: 8.0.426.27-electron.0
OS: Windows_NT x64 10.0.18363

@turowicz
Copy link

Same issue here on Ubuntu 20.04

[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Connected","Payload":null}
[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"ProtocolVersion","Payload":1}
[info]: OmniSharp.DotNetTest.DebugSessionManager
        Debug session started.
Received response for /v2/getcodeactions but could not find request.
Received response for /v2/getcodeactions but could not find request.
/root/.vscode-server/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/run: line 28: 65649 Killed                  "${mono_cmd}" "${omnisharp_cmd}" "$@"

@lonix1
Copy link

lonix1 commented Sep 12, 2021

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.)

@msigut
Copy link

msigut commented Oct 8, 2021

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 ...

@lonix1
Copy link

lonix1 commented Mar 14, 2022

Some feedback: since upgrading to the net6-based o#, I no longer have debugging crashes. 😄

@smargoli2
Copy link

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!

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

Successfully merging a pull request may close this issue.