Skip to content

Debuggers & profilers broken on Node.js 5.2 #4297

Closed
@ofrobots

Description

@ofrobots

Debuggers and profilers are broken in Node.js 5.2 by the recent changes to how we wrap modules. Specifically the PRs: #4254 and #2867 are causing issues.

The following test-case works with Node.js 5.1.1, but doesn't work with Node.js 5.2:

var vm = require('vm');
var Debug = vm.runInDebugContext('Debug');
var foo = require('./foo.js');

Debug.setListener(function (e,s,d) {
  console.log('debug event', e);
});
Debug.setBreakPoint(foo);
foo('world');
console.log(Debug.showBreakPoints(foo));

Where foo.js is

module.exports = function bar(who) { console.log('hello', who); }

The expected output is:

debug event 1
hello world
(who) { [B0]console.log('hello', who); }

This has to do with how V8 interprets line_offset provided with the scripts. V8 ends up setting the breakpoint at the wrong line, or in this case, not setting the breakpoint at all because it looks like a breakpoint beyond the end of the file.

Profilers are broken for a similar reason as the line-ticks are going to be reported incorrectly.

I am still investigating the issue to figure out if it is a bug in V8. In the meanwhile, I would argue that #4254 and #2867 should be reverted.

@cjihrig @bnoordhuis Thoughts?
/cc @nodejs/v8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions