dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.87k stars 675 forks source link

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

Open xcellsoft opened 6 years ago

xcellsoft commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

robbash commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

akshita31 commented 6 years ago

@DustinCampbell I made a fix to omnisharp-roslyn that handles a problem with the debug session : https://github.com/OmniSharp/omnisharp-roslyn/pull/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 commented 6 years ago

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 commented 6 years ago

@vhetet Can you provide some more repro steps.

vhetet commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

@DustinCampbell Can you help us here: https://github.com/OmniSharp/omnisharp-vscode/issues/2398#issuecomment-417413477. There are similar issues that are getting a lot of traction : https://github.com/OmniSharp/omnisharp-vscode/issues/2106

seesharper commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.

akshita31 commented 6 years ago

@rchande This should not be closed right ?

rchande commented 6 years ago

@akshita31 Oops. Looks like GitHub helpfully closed it for me automatically.

xcellsoft commented 6 years ago

FYI, mine still crashes all the time (windows) - i'm now really efficient at hitting Ctrl-P + Reload Window, I keep updating to the next beta's in hope it gets fixed. I wish i had more time to troubleshoot the exact the issue to help solve the problem. I lose the debugger on certain exceptions thrown when debugging, also when stopping the debugger in certain situations, and then about half the time on syntax errors when trying to debug.

I'm currently running

OmniSharp server started. Path: C:\Users\ChrisBaird.AzureAD.vscode\extensions\ms-vscode.csharp-1.17.0-beta2.omnisharp\1.32.5\OmniSharp.exe PID: 27996

seesharper commented 5 years ago

It is starting to fail om my machine again.

After debugging a test, all language services are dead.

I noticed this in the output though

image

seesharper commented 5 years ago

I can also confirm that the OmniSharp process dies.

Before debugging test

image

After debugging test

image

seesharper commented 5 years ago

Here is what happens in the extension

log.ts:157  INFO no standard startup: not just one text editor
notificationsAlerts.ts:38 Error: File not found (file:///Users/bernhardrichter/Library/Application Support/Code/logs/20181202T124416/main.log)
    at new t (files.ts:624)
    at fileService.ts:335
    at Object.v [as _notify] (winjs.base.js:1230)
    at Object.enter (winjs.base.js:916)
    at n.Class.derive._oncancel._run (winjs.base.js:1089)
    at n.Class.derive._oncancel._error (winjs.base.js:1062)
    at async.ts:670
    at extfs.ts:57
    at /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules.asar/graceful-fs/polyfills.js:284
    at FSReqWrap.oncomplete (original-fs.js:152)
t.onDidNotificationChange @ notificationsAlerts.ts:38
log.ts:169   ERR File not found (file:///Users/bernhardrichter/Library/Application Support/Code/logs/20181202T124416/main.log): Error: File not found (file:///Users/bernhardrichter/Library/Application Support/Code/logs/20181202T124416/main.log)
    at new t (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:1416:348)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3331:741
    at Object.v [as _notify] (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:163:532)
    at Object.enter (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:166:784)
    at n.Class.derive._oncancel._run (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:168:100)
    at n.Class.derive._oncancel._error (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:167:635)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:219:870
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:310:58
    at /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules.asar/graceful-fs/polyfills.js:284:29
    at FSReqWrap.oncomplete (original-fs.js:152:21)
notificationsAlerts.ts:38 Error: File not found (file:///Users/bernhardrichter/Library/Application Support/Code/logs/20181202T124416/sharedprocess.log)
    at new t (files.ts:624)
    at fileService.ts:335
    at Object.v [as _notify] (winjs.base.js:1230)
    at Object.enter (winjs.base.js:916)
    at n.Class.derive._oncancel._run (winjs.base.js:1089)
    at n.Class.derive._oncancel._error (winjs.base.js:1062)
    at async.ts:670
    at extfs.ts:57
    at /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules.asar/graceful-fs/polyfills.js:284
    at FSReqWrap.oncomplete (original-fs.js:152)
t.onDidNotificationChange @ notificationsAlerts.ts:38
log.ts:169   ERR File not found (file:///Users/bernhardrichter/Library/Application Support/Code/logs/20181202T124416/sharedprocess.log): Error: File not found (file:///Users/bernhardrichter/Library/Application Support/Code/logs/20181202T124416/sharedprocess.log)
    at new t (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:1416:348)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3331:741
    at Object.v [as _notify] (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:163:532)
    at Object.enter (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:166:784)
    at n.Class.derive._oncancel._run (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:168:100)
    at n.Class.derive._oncancel._error (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:167:635)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:219:870
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:310:58
    at /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules.asar/graceful-fs/polyfills.js:284:29
    at FSReqWrap.oncomplete (original-fs.js:152:21)
console.ts:134 [Extension Host] rejected promise not handled within 1 second
t.log @ console.ts:134
t._logExtensionHostMessage @ extensionHost.ts:437
(anonymous) @ extensionHost.ts:244
emitTwo @ events.js:126
emit @ events.js:214
emit @ internal/child_process.js:772
_combinedTickCallback @ internal/process/next_tick.js:141
_tickCallback @ internal/process/next_tick.js:180
mainThreadExtensionService.ts:42 [ms-vscode.csharp]This socket is closed
e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:42
t._doInvokeHandler @ rpcProtocol.ts:439
t._invokeHandler @ rpcProtocol.ts:424
t._receiveRequest @ rpcProtocol.ts:341
t._receiveOneMessage @ rpcProtocol.ts:271
(anonymous) @ rpcProtocol.ts:146
e.fire @ event.ts:145
a @ ipc.net.ts:103
n._socketDataListener @ ipc.net.ts:132
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594
mainThreadExtensionService.ts:43 Error: This socket is closed
    at Socket._writeGeneric (net.js:726:18)
    at Socket._write (net.js:786:8)
    at doWrite (_stream_writable.js:387:12)
    at writeOrBuffer (_stream_writable.js:373:5)
    at Socket.Writable.write (_stream_writable.js:290:11)
    at Socket.write (net.js:704:40)
    at OmniSharpServer._makeRequest (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/server.js:529:35)
    at RequestQueue.OmniSharpServer._requestQueue.requestQueue_1.RequestQueueCollection.request [as _makeRequest] (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/server.js:96:109)
    at RequestQueue.processPending (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/requestQueue.js:73:29)
    at RequestQueueCollection.drain (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/requestQueue.js:137:33)
    at RequestQueueCollection.enqueue (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/requestQueue.js:107:14)
    at Promise (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/server.js:409:36)
    at new Promise (<anonymous>)
    at OmniSharpServer.<anonymous> (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/server.js:401:27)
    at Generator.next (<anonymous>)
    at /Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/server.js:11:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/server.js:7:12)
    at OmniSharpServer.makeRequest (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/server.js:395:16)
    at Object.<anonymous> (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/utils.js:174:23)
    at Generator.next (<anonymous>)
    at /Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/utils.js:11:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/utils.js:7:12)
    at Object.debugTestStop (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/omnisharp/utils.js:173:12)
    at DebugEventListener.onDebuggingStopped (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/features/dotnetTest.js:429:21)
    at Socket.socket.on (/Users/bernhardrichter/.vscode/extensions/ms-vscode.csharp-1.17.1/out/src/features/dotnetTest.js:364:34)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)
e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:43
t._doInvokeHandler @ rpcProtocol.ts:439
t._invokeHandler @ rpcProtocol.ts:424
t._receiveRequest @ rpcProtocol.ts:341
t._receiveOneMessage @ rpcProtocol.ts:271
(anonymous) @ rpcProtocol.ts:146
e.fire @ event.ts:145
a @ ipc.net.ts:103
n._socketDataListener @ ipc.net.ts:132
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594
seesharper commented 5 years ago

@rchande @akshita31 Thoughts about this?

UPDATE:

I used to be on

Mono JIT compiler version 5.14.0.177 (2018-04/f3a2216b65a Fri Aug  3 09:28:16 EDT 2018)

after update to

Mono JIT compiler version 5.16.0.220 (2018-06/bb3ae37d71a Fri Nov 16 17:12:11 EST 2018)

the problem seem to be resolved.

Thanks to @filipw for suggesting a mono update

rchande commented 5 years ago

@seesharper That's interesting, thanks for the info. I did debug this at some point and was only able to determine that the mono process was crashing. I wasn't ever able to break on any .NET exceptions, so maybe it was a mono bug?

seesharper commented 5 years ago

@rchande I could not see any .Net exceptions either. OmniSharp-Roslyn simply died without anything being logged. My best guess is that something rather critical happened inside mono and that is why the process died. Maybe it would be a good idea to require at least 5.16 somehow?

filipw commented 5 years ago

indeed, at the moment we only require 5.8 of mono https://github.com/OmniSharp/omnisharp-roslyn/blob/master/build.json#L9

akshita31 commented 5 years ago

@vhetet @bihe Can you try updating the mono version as stated above and checking if the error still reproduces ?

vhetet commented 5 years ago

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

vhetet commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

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

seesharper commented 5 years ago

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

RussKie commented 5 years ago

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

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 commented 5 years ago

Another +1 to fix this issue.

 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 commented 5 years ago

@rchande Any updates on this?

ethan-deng commented 5 years ago

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

polterguy commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

Still exists as an issue for me as well.