[AC-804] iOS: Debugger: actual breakpoint location is off by one in require()'d js modules
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2015-08-30T07:17:08.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Appcelerator CLI, Titanium SDK & CLI |
Labels | debugger-ios, ios |
Reporter | Olivier Morandi |
Assignee | Chris Barber |
Created | 2014-09-05T09:23:15.000+0000 |
Updated | 2016-03-08T07:37:04.000+0000 |
Description
Since Ti SDK 3.3.0 (but not with earlier versions), when setting a breakpoint in a common js module the JSCore debugger will suspend on the previous line. This is not immediately evident in Ti Studio, since the debugger UI highlights the expected line.
The following code can be used to reveal the wrong behaviour:
exports.doSomething = function() {
Ti.API.info("line 2");
Ti.API.info("line 3");
Ti.API.info("line 4");
};
var bt = require("mymodule").doSomething();
With a breakpoint set at line 4 of the mymodule.js file, the execution is suspended at line 3, with the console output showing only
{noformat}
[INFO] line 2
{noformat}
This is caused by the commonJS wrapping code introduced by the -\[KrollBridge loadCommonJSModule:withSourceURL:\]
method, which actually adds a line on top of a file being require()'d, thus creating a discordance between the code parsed by JSCore and that viewed by the editor.
Comments
- Olivier Morandi 2014-09-05