Titanium JIRA Archive
Appcelerator Community (AC)

[AC-804] iOS: Debugger: actual breakpoint location is off by one in require()'d js modules

GitHub Issuen/a
Resolution Date2015-08-30T07:17:08.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator CLI, Titanium SDK & CLI
Labelsdebugger-ios, ios
ReporterOlivier Morandi
AssigneeChris Barber


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.


  1. Olivier Morandi 2014-09-05

JSON Source