Search code examples
node.jsnode-debugger

Node debug - undefined error


I was exploring node debugger and I am stuck at the problem. I have a debugging.js file with following content

var http = require("http");
function process_request(req, res) {
    var body = 'Thanks for calling!\n';
    var content_length = body.lenggth ;
    res.writeHead(200, {
        'Content-Length': content_length,
        'Content-Type': 'text/plain'
    });
    res.end(body);
}

var s = http.createServer(process_request);
s.listen(8080);

Note that there is an mistake on line 5. This is done intentionally to debug the problem. Now I tried running node using node debug debugging.js. While this didn't gave any error. Calling setBreakpoint(5) resulted in following error.

Warning: script 'undefined' was not loaded yet.

_debugger.js:1399
      var escapedPath = script.replace(/([/\\.?*()^${}|[\]])/g, '\\$1');
                           ^
TypeError: Cannot call method 'replace' of undefined
    at Interface.setBreakpoint (_debugger.js:1399:31)
    at repl:1:1
...

Environment : Debian Linux3.2.0, Node JS - V0.13.0-pre

Can someone tell me, what should be done to resolve this?

I found post, which seems to have similar problem, but it seems to be a year old post and I am not sure whether the fix is available in the node version, I am using.


Solution

  • Well it seems to be a problem with the node V0.13.0-pre, I am using on Linux. I tried same code on Windows with node v0.10.33 and its working well. All the debugging commands are working as expected.