Debugging javascript with chrome

I’m on windows, and JS debugging is not working using chrome.

I debug a “index.html” file with a js script with only one line “var one = 1”. I have a breakpoint on that line, but komodo does not stop on that line.

When I debug, komodo opens 2 chrome browsers :

file:///C:/program%20files%20(x86)/google/chrome/application/73.0.3683.86/
file:///D:/htdocs/project/index.html

And I see this in komodo :

INFO:chrome.dbgp.main:Debugging ‘file://D:\htdocs\project\index.html’ over localhost:61553 on Chrome 127.0.0.1:9222
INFO:chrome.dbgp.DBGPClient:Connection to IDE established.
INFO:chrome.dbgp.ChromeClient:Connection to Chrome established.
INFO:chrome.dbgp.DBGPClient:Debugging started.

Then, if I refresh the “index.html” page in chrome :

ERROR:chrome.dbgp.DBGPClient:Exception occurred in ‘run’
Traceback (most recent call last):
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 463, in processCommands
getattr(self, handler)(argv, data)
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 831, in onRun
self._wait()
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 786, in _wait
if not self.chrome.processMessages(True):
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 169, in processMessages
listener.callback(data, listener)
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 628, in onScriptParsed
lambda response : (
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 219, in send
self.processMessages() # retrieve response
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 188, in processMessages
command.callback(command)
File “C:\Program Files (x86)\ActiveState Komodo IDE 11\lib\support\dbgp\chromelib\dbgp.py”, line 630, in
‘chrome_id’: response.data[‘breakpointId’].value,
TypeError: ‘NoneType’ object has no attribute ‘getitem

Does js debugging using chrome supposed to work on windows ?

@trogne, yes it should work.

Can you confirm the version of Node that you’re using and also that you have Prefs > Debugger > Initial break behavior: Break on first executable line enabled?

Also note the limitation mentioned in the docs due to how Chrome debugger works:

Debuggable JavaScript must be executed by event-driven code, such as an “onclick” event handler

  • Carey

Nvm the NodeJS version. I was mixing debuggers in my head.

“Break on first executable” was already enabled.

NodeJS : v10.13.0
npm : 6.4.1

I’m trying debugging from the “index.html” file, and directly from the .js file (using both “Javascript” and “Node” file type).

If I debug the “index.html”, with this line in the js file:

document.getElementById('h1').onclick = () =>console.log('blabla');

it doesn’t stop at breakpoint, but I see the console.log in komodo’s debug output.

I’m not sure exactly what’s going on here but if you give some body to that function the breakpoint seems to get picked up.

document.getElementById('h1').onclick = () => {
    console.log('blabla');  //set breakpoint here
}

I’ve filed a bug:

  • Carey

I have to debug the .js file, which does not make sense, since the browsers starts with 2 tabs :

“file:///C:/program%20files%20(x86)/google/chrome/application/73.0.3683.86/”
and
“file:///D:/htdocs/project/myscript.js”

Then I have to go to index.html :
“file:///D:/htdocs/project/index.html”

Now I can click to trigger the event, and it stops at the breakpoint on the callback.

But if you say that javascript debugging is only possible on events, then I’ll stcik with browser debugging.

I don’t understand the point of what you wrote above except the last line:

Yes, this is how Remote Chrome debugger has always worked as far as I know.

  • Carey