Inspector Breakpoints "Jumping" to function definition


#1

I’m trying to place a breakpoint at Line 166 of linter-elixirc/lib/init.coffee which is part of the linter-elixirc package. Whenever I try to place the breakpoint it jumps to Line 165, the same happens if I place the breakpoint at Line 162, it jumps to Line 153 - in both cases it jumps to line that declares the function that the line contains:

At this stage I am assuming I am doing something wrong, as searching around the Atom, Chrome and Chromium forums and bug reports sections doesn’t seem to bring up any ideas of how to fix it. If however it turns out to be a bug then I’m happy to report it as a GitHub issue.


#2

Chromium’s debugger cannot properly translate JS Breakpoints into CoffeeScript line numbers.

lintMix = (textEditor) =>
      helpers.exec(@mixPath, ['compile'], getOpts(textEditor))
        .then (handleResult(textEditor))

translates to (something like)

lintMix = (function(_this) {
  return function(textEditor) {
    return helpers.exec(_this.mixPath, ['compile'], getOpts(textEditor)).then(handleResult(textEditor));
  };
})(this);

The debugger simply does not know how to map 3 lines of CoffeeScript into 5 lines of JavaScript (even if it appears to be obvious). This usually does not happen if you place a breakpoint in the middle of a block (in your case, placing a breakpoint at line 161 should work).

If you don’t want to deal with this issue, you can go to the debugger’s source code navigator and select the JavaScript versions of your files (they have a .coffee extension but they contain JavaScript code).


#3

Interesting, coming from a .NET background where breakpoints are set a lexical token level rather than a line level. Does this mean that in JavaScript all breakpoints are set at a line level? so if you had the following code:

let a = 2; let b = 3, let c = a + b

It would be impossible to set a breakpoint on let b = 3?


#4

Even more interesting when I set a breakpoint in the compiled JavaScript, the breakpoint is actually set in the CoffeeScript file and the focus jumps to the compiled CoffeeScript:


#5

I beleive you can generate source map to allow debugger to follow coffeescript files.
//# sourceMappingURL=path/to/your/sourcemap.map


#6

That was how I understood SourceMaps myself, they seem to be working in general for Electron/Atom as you can set a breakpoint and then step through the CoffeeScript, however breakpoints seem to be a bit glitchy. I don’t know enough about JavaScript, CoffeeScript or SourceMaps to be able to tell if this is a misconfiguration on my part or a bug in Atom, Electron or Chromium.


#7

I don’t think this is a coffeescript problem. I use source-maps and see this all the time. I think the problem is that sections of code cannot have breakpoints set when they haven’t been compiled yet. In other words there is nowhere to put the breakpoint instruction.