TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Visual studio 2013 freezes when debugging TypeScript

Open ghost opened this issue 11 years ago • 27 comments

Hi,

We use Visual Studio 2013 Premium Update 4 and develop applications in TypeScript 1.4. We have a very serious issue, when we start debugging the code, entering into another method in another class would freeze the whole Visual Studio. It is then stalled for at least few minutes. The only way to quickly work with the Visual Studio again is by terminating the Visual Studio process from the task manager and restart the application again.

Any ideas on how to solve this issue? Thanks in advance.

By the way, I posted the same thing in CodePlex, I received a reply asking me to use GitHub instead. Reference link: https://typescript.codeplex.com/workitem/2657

Thanks again.

ghost avatar Feb 10 '15 10:02 ghost

Are you able to share the project where you're seeing this or is it happening in all projects?

danquirk avatar Feb 10 '15 22:02 danquirk

Looks very much like a duplicate of #1994

jods4 avatar Feb 12 '15 00:02 jods4

Totally the same problem here! Looking forward for a bugfix! Greetz

ghost avatar Feb 12 '15 08:02 ghost

Hi, @danquirk : We tried to setup a small project for this, however the issue could not be reproduced. But I have 5 medium sized projects, (which unfortunately cant share) has this issue. @jods4 : yes, the issue looks similar. It happens also with Visual Studio 12, TypeScript 1.

Thanks again.

ghost avatar Feb 12 '15 08:02 ghost

I had similar problem also so maybe this information will help. The problem I had was stepping into F11 another module. If the module you are going to already had a break point there you could still F5 to get there.

What worked for me (so far) but didn't really make any sense to me...I toggled the "Generate source maps" option in project properties so that the option was added to the project file and set to "True" True

Also, to unfreeze VS, instead of killing the devenv.exe task you can kill iisexpress.exe task and then VS will come back. This doesn't fix the problem but at least you don't lose the VS process.

Hope this helps and looking forward to a fix.

jimbarrett33 avatar Feb 18 '15 19:02 jimbarrett33

Hello @jbarr33 Thanks a lot for your suggestions.

A good thing and a bad thing. The good is that I can now safely kill the process iisexpress.exe with out killing the Visual studio 2013. I should already say a big thanks to you for this little trick.

Secondly the bad thing, I tried with the "Generate Source Map", however it still hangs. If you are interested, my TypeScript build looks similar to this:

image

If any of you find any issues with this, please update me.

Thanks again for your help and support!

ghost avatar Feb 19 '15 09:02 ghost

Hi Santoshnilla et al,

Well the problem came back today and I spent basically the day (another full day) trying to figure this out because I basically can't work (at least efficiently). Maybe what "fixed" it yesterday wasn't the project properties but something else I was trying...

It seems that if the module/code file that you are stepping into has a breakpoint inside any function then Visual Studio doesn't hang and steps into the function you are trying to step into. The breakpoint does not have to be in the function you're stepping into and it can even be a disabled breakpoint! So theoretically if you're in a debugging session you generally are in the same targeted files so you could go into these files and add a disabled breakpoint somewhere before you start debugging.

This is obviously just an annoying work around that seems to be working for me so far. I'm curious if this will work for others.

This bug needs to be fixed. Hopefully in addition to above this info will help someone on the MS VS and/or TS team that knows the code cause for me it's hard to narrow down any further:

  • I tried disabling extensions -- Web Essentials, ReSharper etc. -- and it did not help
  • When you kill the iisexpress process and you pop back into Visual Studio you do land inside the function you were trying to step into

Hope this helps.

jimbarrett33 avatar Feb 19 '15 22:02 jimbarrett33

Any idea of target date for TypeScript 1.5 or the status of this problem? Although there are workarounds VS debugging is becoming a real problem in terms of productivity. I can't say enough good things about TypeScript and I won't stop using it but this problem makes it difficult to be efficient. (But it is still 1000% better than writing JavaScript natively :).

Thanks.

jimbarrett33 avatar Mar 04 '15 18:03 jimbarrett33

This is making dev difficult for me too. If I forget to put a break in the target file, I have to crash the iisexpress sub process as I too found. (see jbarr33 "Hi Santoshnilla et al," comment above)

More error information that may help ... My output debug window after the crash shows:

The program '[6760] iexplore.exe' has exited with code 0 (0x0). Document http://localhost:49800/App/viewmodels/products.ts read failed: Unable to connect to the remote serverThe program '[6024] iisexpress.exe' has exited with code 1 (0x1). The program '[6024] iisexpress.exe: Program Trace' has exited with code 0 (0x0).

A fix would be much appreciated.

rockResolve avatar Mar 09 '15 21:03 rockResolve

I have suddenly started getting this all the time as well. Some additional information, I attached a debugger to Visual Studio when it was frozen, and see the below call stack, which seems to indicate the issue is with fetching the source file through the TypeScriptSourceMapReader.

mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) + 0x20 bytes 
    mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) + 0x28 bytes    
    System.dll!System.Net.LazyAsyncResult.WaitForCompletion(bool snap) + 0xd1 bytes 
    System.dll!System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult asyncResult) + 0x54 bytes   
    TypeScriptSourceMapReader.dll!TypeScriptSourceMapReader.SourceMapUrlHelper.GetWebResponse(System.Uri uri) + 0x95 bytes  
    TypeScriptDebugEngine.dll!TypeScriptDebugEngine.DebugMonitor.TypeScriptDocumentContentProvider.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmScriptDocumentProvider.GetContent(Microsoft.VisualStudio.Debugger.Script.DkmScriptDocument scriptDocument, bool enableContentEvents, out uint[] sectionDividers) + 0x82 bytes    
>   Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.EntryPoint.IDkmScriptDocumentProvider_GetContent(System.IntPtr pvClassInfo, System.IntPtr ScriptDocument, byte EnableContentEvents, ref System.IntPtr Content, ref NativeXapiArray SectionDividers) + 0x79 bytes 

rwyborn avatar Mar 12 '15 03:03 rwyborn

Some follow up information:

  • I have checked multiple freezes now, and it is always the above call stack when the freeze occurs.
  • If I inspect the URI in the debugger of the HttpWebRequest, it is always the URI of the typescript file that is being stepped into
  • If I open up a web browser and input that same URI, the browser just loops forever trying to load it.
  • So it seems that iisexpress itself is freezing

And last of all, the problem goes away completely if in the visual studio project settings I disable:

  • Web->Debuggers->ASP.NET

rwyborn avatar Mar 12 '15 03:03 rwyborn

Thank you rwyborn. Good idea attaching the debugger.

The work around of disabling Web->Debuggers->ASP.NET works for me and since I'm currently all client dev. A small issue is that in my project I also have the option Start Action = "Don't open page. Wait for a request from and external app" and if I uncheck ASP.NET debugger then Visual Studio alerts me with a message that this is a problem every time I try to debug. Not a big deal since I don't have to end my debugging session often.

Great news on the fix below!

Thanks

jimbarrett33 avatar Mar 12 '15 11:03 jimbarrett33

I just checked in a fix, which should prevent VS from hanging indefinitely when a .map/.ts file can not be loaded. This should help with the experience.

I'll leave this open so you can share workarounds until the next version of TS is released.

Can someone share the Asp.net/IIS stack when requesting the ts file in the browser and VS?

paulvanbrenk avatar Mar 12 '15 19:03 paulvanbrenk

@paulvanbrenk I was going to try your fix, assuming it is in master?. How do I make visual studio use the locally compiled node tsc and services to test this? (Currently I am running VS2013 with the Typescript 1.4 extension).

Note that in 1.4 it is not possible to get an Asp.NET/IIS stack when the freeze occurs because of a catch 22. The freeze only happens if Asp.NET debugging is enabled. But if Asp.NET debugging is enabled then the VS2013 instance that freezes owns the exclusive debugger attachement, so it is not possible to attach another external debugger to capture the stack.

I am hoping that with your fix (and assuming IIS still freezes), I can capture the IIS stack with the already running VS2013 instance.

rwyborn avatar Mar 25 '15 04:03 rwyborn

@paulvanbrenk

I just tried using the latest TS from master and it did not resolve the issue. My VS is still locking up with the same stack trace as @rwyborn was getting.

I am currently running VS2013 with the TS 1.4 extensions. I pulled the latest TS source and followed the instructions to build and install it into my 1.4 directory.

Let me know if there is anything I can do to get you any information you need to fix this.

Thanks

pmiddleton avatar Apr 03 '15 21:04 pmiddleton

The fix is on the VS managed side, not in the TS script side. So using the latest TS from master will not address the issue. You'll only see the fix once the managed side gets pushed out in some future update.

CyrusNajmabadi avatar Apr 04 '15 00:04 CyrusNajmabadi

@CyrusNajmabadi so when/how do we get a hold of the managed side update for testing? I don't want to wait until 1.5 is released only to then find that the issue is still present.

rwyborn avatar Apr 04 '15 04:04 rwyborn

@rwyborn sorry for the delay, but the VS plugin changes ship on VS scheduled. We should have something ready with the next VS release.

mhegazy avatar Apr 06 '15 17:04 mhegazy

Hrm @mhegazy you appear to have closed this issue without any confirmation from the original reporters that the problem is actually fixed. Or were you able to reproduce it internally and verify it is now fixed?

rwyborn avatar Apr 09 '15 23:04 rwyborn

The fix should be out with the next VS release. if it still repros we can always reopen the issue. Just closing it for now as there is not actions to be taken until the next release is public.

mhegazy avatar Apr 09 '15 23:04 mhegazy