sokolovstas / SublimeWebInspector

Web Inspector allow you debug Javascript right in the editor
http://sokolovstas.github.com/SublimeWebInspector
MIT License
2.35k stars 93 forks source link

Can't add breakpoint #17

Open bbeckford opened 11 years ago

bbeckford commented 11 years ago

I can get chrome to open and start debugging and I have the console working, but when I try to add a breakpoint nothing happens.

I have the following errors in the bottom console window:

[4560:2672:0318/093557:ERROR:connection.cc(730)] sqlite error 19, errno -2: PRIMARY KEY must be unique [4560:6612:0318/093602:ERROR:textfield.h(162)] NOT IMPLEMENTED

Thanks for your hard work, this could potentially be hugely useful.

sokolovstas commented 11 years ago

Please see #11

bbeckford commented 11 years ago

I'll try a simple project, my problem is on Windows 8 btw

bbeckford commented 11 years ago

Ok I've tried a very simple project and it still doesn't add breakpoints, any other ideas?

bbeckford commented 11 years ago

Hmm when I tried before I was using jQuery from Google's CDN, I downloaded it and breakpoints now work.

Does every single script have to be loaded locally, even if you aren't interested in debugging it? If so is there a way around this? I don't always have every script locally on my machine, and I often use the SFTP package to upload to servers etc.

sokolovstas commented 11 years ago

Hmm this sound strange. Can you send me a sample project where breakpoints doesn't work?

bbeckford commented 11 years ago

Here is the example using the Google jQuery CDN - https://dl.dropbox.com/u/3615425/web_inspector_test.zip

joezimjs commented 11 years ago

I'm using Windows 7 and absolutely nothing happens when I use the Add/Remove Breakpoint command.

jevakallio commented 11 years ago

I'm on Windows 7 also. Breakpoints work in a simple project, where scripts are included with <script> tags. In a more complex application using RequireJS the Add/Remove Breakpoint command does nothing, as reported by @joezimjs.

sokolovstas commented 11 years ago

@bbeckford you have error in your htm file src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"

I fixed it and run from local server on path 'http://localhost/adminui/web_inspector_test/index.htm'

and everything works fine!

@fencliff could you provide a sample project with RequireJS

bbeckford commented 11 years ago

@sokolovstas, silly me!

However, it seems in my testing any javascript error will mean I can't add a breakpoint. For example I have a dev site that shows an error due to no linked in api key being set, something I usually ignore whilst I'm building and debugging the rest of the site but would stop me from using web inspector, is this repairable?

Thanks

sokolovstas commented 11 years ago

@bbeckford please provide more details: 1) what URL entered in browser 2) what URL of debugging file 3) what folder added to sublime project 4) what local file name

I believe this is simple file and path errors. Also you can try close tab, open again and then connect inspector.

sokolovstas commented 11 years ago

For now now matching algorithm is: 1) Take file url -> "https://github.com/sokolovstas/SublimeWebInspector/issues/17.JS" 2) Delete first http and host -> "sokolovstas/SublimeWebInspector/issues/17.JS" 3) Try open file by path "sokolovstas/SublimeWebInspector/issues/17.JS" 4) If can't find remove step by step from url parts splitted by "/" 5) Try open file by path "SublimeWebInspector/issues/17.JS" 6) Try open file by path "issues/17.JS" and so on

jevakallio commented 11 years ago

@sokolovstas, I created a repro which shows that the issue was not in RequireJS script loading after all. The problem appears to be that the root folder opened in Sublime Text was the one "above" the web page root, so that my source url in the browser was /file.js, whereas the path in Sublime was /source/file.js. The issue was solved by only opening the source directory in Sublime. This is slightly inconvenient, but definitely manageable.

This project is awesome. Thanks for all the good work!

sokolovstas commented 11 years ago

You must have at lease one folder with all content because plugin search for files in project folders!

sokolovstas commented 11 years ago

@bbeckford I can close issue? All works fine?

joezimjs commented 11 years ago

OK so I have several instances where this isn't working, in different ways.

1: No errors given by the plugin. Just nothing was happening. In this case I had an error in the script, which was why it wasn't setting a breakpoint. This is bad because when I have errors, I'm more likely to WANT to use a breakpoint to try to figure it out.

2: Similar issue to @fencliff I believe. My project structure looks like this (the structure is the same in #1): Main Folder |-- public | |-- js ........

So the browser's root folder (/) is "public". In this case I get this error in the little console below the inspector: [8196:6920:0320/073456:ERROR:external_registry_loader_win.cc(103)] File C:\Program Files (x86)\OApps\chromeaddon.crx for key Software\Google\Chrome\Extensions\kincjchfokkeneeofpeefomkikfkiedl does not exist or is not readable.

3: Just for kicks, I made "public" the root of the project and tried debugging. If the error that I mentioned in #1 is there, it'll let me put the breakpoint, but when I refresh the browser or do anything, it skips right past the breakpoint. Completely useless.

If I fix the error, stop debuggin, start debugging again, try setting a breakpoint, I get a popup error saying "Could not resolve breakpoint".

So basically, I've tried everything mentioned in this issue and still nothing works for me.

sokolovstas commented 11 years ago

@joezimjs Please provide sample project and path where to place it on localhost. I can't find bugs by description only. I need to test something.

PS I have fixed some issues with setting breakpoints on ST3 branch today.

joezimjs commented 11 years ago

https://github.com/joe-zim-javascript-blog/ButlerBoss is the project when you run node butlerboss it'll start up the server on localhost:8080

sokolovstas commented 11 years ago

Ok I have fixed path issue, now file mapping working fine. Where to try set breakpoint?

joezimjs commented 11 years ago

I was just trying to set it in the main.js file.

sokolovstas commented 11 years ago

On what line? If on 8 line, there I have Exception and Javascript just falling and breakpoints not work here. But in new version I made a new property "pause_on_exceptions" and it set to "uncaught" if you have uncaught exception debugger will pause there

joezimjs commented 11 years ago

Set a breakpoint anywhere that would normally work. If it works, great; if it doesn't then we'll have to figure it out.

sokolovstas commented 11 years ago

Screen Shot 2013-03-21 at 4 26 18 PM Screen Shot 2013-03-21 at 4 26 27 PM

And debugger paused on line 4, 10, 7, 7 and uncaught Exception and stop

joezimjs commented 11 years ago

Is your latest version available through the Package Installer?

sokolovstas commented 11 years ago

Yes, you use sublime 3? You need just restart sublime and packages will be updated

joezimjs commented 11 years ago

No I'm on Sublime 2

joezimjs commented 11 years ago

Right now I'm getting this in the console:

[14268:11872:0321/074231:ERROR:external_registry_loader_win.cc(104)] File C:\Program Files (x86)\OApps\chromeaddon.crx for key Software\Google\Chrome\Extensions\kincjchfokkeneeofpeefomkikfkiedl does not exist or is not readable. [14268:14272:0321/074236:ERROR:textfield.h(162)] NOT IMPLEMENTED

joezimjs commented 11 years ago

That's just after trying to start Chrome. Nothing really works after that.

sokolovstas commented 11 years ago

I have changed path from version to branch need to wait until wbond package manager reload package.

joezimjs commented 11 years ago

I'm not sure what that means. I should just wait?

sokolovstas commented 11 years ago

Try to remove package and install it again now.

joezimjs commented 11 years ago

Still getting

[5200:13428:0321/093815:ERROR:external_registry_loader_win.cc(104)] File C:\Program Files (x86)\OApps\chromeaddon.crx for key Software\Google\Chrome\Extensions\kincjchfokkeneeofpeefomkikfkiedl does not exist or is not readable. [5200:12244:0321/093820:ERROR:textfield.h(162)] NOT IMPLEMENTED

sokolovstas commented 11 years ago

This is not a problem if Chrome started correctly and working

sokolovstas commented 11 years ago

Also today I have fixed some line number issues and seems it work fine on your project.

Integralist commented 11 years ago

Hi, I've installed this extension "Web Inspector 3" today and am having issues with setting break points (all other features seem to work).

I'm on Mac OSX 10.8.3

I've updated the path in "Settings - User" (as I wasn't able to change the setting in the Default for some reason?) to...

{
    "chrome_path":
    {
        "osx": "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
    }
}

Note: I've since gone back to "Settings - User" and it has changed itself to look like this...

{
    "breaks":
    {
    },
    "chrome_path":
    {
        "osx": "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
    }
}

...notice the extra "breaks" property?

My set-up is as follows...

index.html file which links to a JavaScript file (both in a /debug/ folder in my localhost directory).

The content of my JavaScript file is...

var testing = (function() {
    counter = 0;

    return function() {
        console.log(counter);
        counter++;
    }
}());

window.setInterval(testing, 5000);

My localhost directory is found here: /Library/WebServer/Documents

So to begin with, within ST3 I run: Cmd+Shift+R and select the option "Start Google Chrome with remote debug port 2222"

I then see the following error...

[3697:1799:0324/114057:ERROR:content_settings_pref_provider.cc(516)] Invalid pattern strings: [*.]78.109.163.36,*
[3697:1799:0324/114057:ERROR:content_settings_pref_provider.cc(400)] Invalid pattern strings: [*.]78.109.163.36,*

I then run Cmd+Shift+R again and this time I choose the option "Add/Remove Breakpoint". My cursor is already on line 6 which is where I wanted to add a break point (counter++;) which then places a black dot on that line (so I assume that has worked?)

I then switch over to Chrome Canary and manually enter the URL http://localhost/debug/

I then switch back to ST3 and run Cmd+Shift+R again and this time I choose the option "Start debugging" which displays "http://localhost/debug/" in the list. I select the URL and the inspector within ST3 starts showing me the logging information from my script but doesn't actually break on the breakpoint at all?

I then find I can't add another breakpoint unless I stop debugging first.

Any ideas on what the issue might be?

Thanks.

JeffreyWay commented 11 years ago

Same here. Everything works except for breakpoints. If I set a breakpoint (even for a simple HTML file and script), absolutely nothing happens.

sokolovstas commented 11 years ago

@Integralist run "Show file mapping" command and post result here please

Integralist commented 11 years ago

@sokolovstas OK first thing worth noting is that I've retried the above steps on my work laptop (same OS version but it's a 2012 retina macbook, where as above I was testing at home on a 2009 17" macbook pro) but this time I didn't get the error...

[3697:1799:0324/114057:ERROR:content_settings_pref_provider.cc(516)] Invalid pattern strings: [*.]78.109.163.36,*
[3697:1799:0324/114057:ERROR:content_settings_pref_provider.cc(400)] Invalid pattern strings: [*.]78.109.163.36,*

...but it still doesn't pause on the break points (thought I'd just let you know in case that error no longer showing was important or not).

I ran the Show file mapping command and it opened a new tab with an empty Array: [] on line 1?

sokolovstas commented 11 years ago

If mapping is empty no file connected from url to your local file systems. All errors on chrome start doesn't mater!

What is your js file url and which folder you add to sublime?

Integralist commented 11 years ago

@sokolovstas

I've just checked the "Settings - User" file again (remember for now I'm testing this on my 2012 macbook) and the file changed to...

"breaks":
    {
        "/Users/markmcdonnell/Desktop/test.js":
        {
            "6":
            {
                "status": "disabled"
            }
        }
    }

...it now shows my test javascript file.

I copied the files to my Desktop and in Chrome manually opened the index.html I copied there

sokolovstas commented 11 years ago

You need to add foder to sublime project. Open file do nothing. Plugin search for file to map only in project folders

Integralist commented 11 years ago

@sokolovstas ok I created a project file test.sublime-project within that desktop folder and the inspector now breaks on the breakpoint, but it doesn't actually display the counter value at the break point?

See the following image as an example...

Screen Shot 2013-03-25 at 14 38 34

sokolovstas commented 11 years ago

Does chrome developer tools show this var? This is global variable, you can evaluate it or click on global and see it then

Integralist commented 11 years ago

@sokolovstas Chrome dev tools can access the testing variable yes, but not the counter variable as is made private within the IIFE ('immediately invoked function expression'). The IIFE executes and returns another function to testing which creates a closure so it has access to counter, but counter isn't globally accessible as it's made private.

draivin commented 11 years ago

Counter is still global in this case, as you did not declare it using var it will be declared on the window scope.

JeffreyWay commented 11 years ago

^

Integralist commented 11 years ago

@sokolovstas aha! cracked it. thanks -> sorry I didn't realise I hadn't declared counter, my bad.

Yes, now that I have declared the variable I can see the breakpoint shows a closure option which I click on and it shows me the counter value.

Thanks for the help!

DanielSiepmann commented 11 years ago

I didn't want to open another Issue just for this one question: It's not possible to use this plugin for complex Projects at the moment? Like Projects with multiple Virtual Hosts?

sokolovstas commented 11 years ago

You can try it and share you thoughts.

Angelkuga commented 8 years ago

@sokolovstas i want to add a breakpoint but my panel only show two choices one is start debugging the other one is toggle breakpoint .there's no add or delete breakpoint option and when i choose the toggle breakpoint it add one breakpoint which status is disabled