Skip to content

Commit

Permalink
module,src: do not wrap modules with -1 lineOffset
Browse files Browse the repository at this point in the history
In b799a74 and
dfee4e3 the module wrapping
mechanism was changed for better error reporting. However,
the changes causes issues with debuggers and profilers. This
commit reverts the wrapping changes.

Fixes: #4297
PR-URL: #4298
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
  • Loading branch information
cjihrig authored and Myles Borins committed Jan 21, 2016
1 parent 8a0cc64 commit 1408f7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ Module.prototype._compile = function(content, filename) {
var wrapper = Module.wrap(content);

var compiledWrapper = runInThisContext(wrapper,
{ filename: filename, lineOffset: -1 });
{ filename: filename, lineOffset: 0 });
if (global.v8debug) {
if (!resolvedArgv) {
// we enter the repl if we're not given a filename argument.
Expand Down
4 changes: 2 additions & 2 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@
};

NativeModule.wrapper = [
'(function (exports, require, module, __filename, __dirname) {\n',
'(function (exports, require, module, __filename, __dirname) { ',
'\n});'
];

Expand All @@ -952,7 +952,7 @@

var fn = runInThisContext(source, {
filename: this.filename,
lineOffset: -1
lineOffset: 0
});
fn(this.exports, NativeModule.require, this, this.filename);

Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-module-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ assert.equal(42, require('../fixtures/utf8-bom.js'));
assert.equal(42, require('../fixtures/utf8-bom.json'));

// Error on the first line of a module should
// have the correct line and column number
// have the correct line number
assert.throws(function() {
require('../fixtures/test-error-first-line-offset.js');
}, function(err) {
return /test-error-first-line-offset.js:1:1/.test(err.stack);
return /test-error-first-line-offset.js:1:/.test(err.stack);
}, 'Expected appearance of proper offset in Error stack');

0 comments on commit 1408f7a

Please sign in to comment.