This project has moved and is read-only. For the latest updates, please go here.

JavaScript debugger

Sep 21, 2013 at 3:10 PM
I use VS2012 ultimate with latest PTVS.
Breakpoints in Python code work well.
Breakpoints in JavaScript are ignored.

Is this a limitation of PTVS?
If not, what are the things to check for to enable JavaScript debugging?

Sep 21, 2013 at 6:11 PM
What kind of JS code is this, and where does it run? Do you mean client-side JS scripts in a web app?
Sep 22, 2013 at 8:44 AM
You are correct. I'm referring to a Django web app: it has the Python server-side, and the JS client-side.
Is it possible to debug the JS? That would be awesome.
Sep 22, 2013 at 11:42 AM
VS does have the ability to debug client-side JavaScript when it is running in IE, by attaching to the IE process using the "Script" code type. We don't do this by default for our web projects, unlike ASP.NET, but you can still attach via Debug -> Attach to Process; pick the IE process that is auto-detected as "Script".

The major annoyance there, however, is that IE will report filenames as it sees them in URLs, which will likely not match the actual name of your view template in a typical Django app - e.g. the URL path will be /foo/ for a template foo.html, and IE will treat this URL as a file with a name "blank". Consequently, your breakpoints in the template won't match, since VS matches them based on filename. If you make the template map to the URL with the same name, or put your JS code in a separate static file with a matching URL (which is usually easier, and is something that you might already be doing, anyway), then breakpoints should work there. Note that even when your breakpoints don't light up, if there's any JS running at all (e.g. a timer function), you should be able to pause debugging, and it should stop in that code.

We need to investigate whether it is possible to tell VS how the project files map to URLs for script debugging purposes. I'm not sure whether this is an extensibility point, as e.g. ASP.NET MVC doesn't support this. Still, feel free to file a feature request to track this.