Giter VIP home page Giter VIP logo

node-inspector's Introduction

Node Inspector

Build Status NPM version Bountysource

Join the chat at https://gitter.im/node-inspector/node-inspector

Overview

Node Inspector is a debugger interface for Node.js applications that uses the Blink Developer Tools (formerly WebKit Web Inspector).

Since version 6.3, Node.js provides a built-in DevTools-based debugger which mostly deprecates Node Inspector, see e.g. this blog post to get started. The built-in debugger is developed directly by the V8/Chromium team and provides certain advanced features (e.g. long/async stack traces) that are too difficult to implement in Node Inspector.

Table of Content

Quick Start

Install

$ npm install -g node-inspector

Start

$ node-debug app.js

where app.js is the name of your main Node application JavaScript file.

See available configuration options here

Debug

The node-debug command will load Node Inspector in your default browser.

NOTE: Node Inspector works in Chrome and Opera only. You have to re-open the inspector page in one of those browsers if another browser is your default web browser (e.g. Safari or Internet Explorer).

Node Inspector works almost exactly as the Chrome Developer Tools. Read the excellent DevTools overview to get started.

Other useful resources:

Features

The Blink DevTools debugger is a powerful JavaScript debugger interface. Node Inspector supports almost all of the debugging features of DevTools, including:

  • Navigate in your source files
  • Set breakpoints (and specify trigger conditions)
  • Step over, step in, step out, resume (continue)
  • Inspect scopes, variables, object properties
  • Hover your mouse over an expression in your source to display its value in a tooltip
  • Edit variables and object properties
  • Continue to location
  • Break on exceptions
  • Disable/enable all breakpoints
  • CPU and HEAP profiling
  • Network client requests inspection
  • Console output inspection

Cool stuff

  • Node Inspector uses WebSockets, so no polling for breaks.
  • Remote debugging and debugging remote machine.
  • Live edit of running code, optionally persisting changes back to the file-system.
  • Set breakpoints in files that are not loaded into V8 yet - useful for debugging module loading/initialization.
  • Embeddable in other applications - see Embedding HOWTO for more details.

Known Issues

  • Be careful about viewing the contents of Buffer objects, each byte is displayed as an individual array element; for most Buffers this will take too long to render.
  • While not stopped at a breakpoint the console doesn't always behave as you might expect. See the issue #146.
  • Break on uncaught exceptions does not work in all Node versions, you need at least v0.11.3 (see node#5713).
  • Debugging multiple processes (e.g. cluster) is cumbersome. Read the following blog post for instructions: Debugging Clustered Apps with Node-Inspector

Troubleshooting

My script runs too fast to attach the debugger.

The debugged process must be started with --debug-brk, this way the script is paused on the first line.

Note: node-debug adds this option for you by default.

I got the UI in a weird state.

When in doubt, refresh the page in browser

Can I debug remotely?

Yes. Node Inspector must be running on the same machine, but your browser can be anywhere. Just make sure port 8080 is accessible.

And if Node Inspector is not running on your remote machine, you can also debug it as long as your local machine can connect it. In this way, you must launch Node Inspector with --no-inject which means some features are not supported such as profiling and consoling output inspection.

So how to debug remote machine with your local Node Inspector?

option 1

$ node-inspector --debug-host 192.168.0.2 --no-inject then open the url http://127.0.0.1:8080/debug?port=5858

option 2

$ node-inspector --no-inject then specify the remote machine address as a host parameter in the url e.g.) http://127.0.0.1:8080/debug?host=192.168.123.12&port=5858

How do I specify files to hide?

Create a JSON-encoded array. You must escape quote characters when using a command-line option.

$ node-inspector --hidden='["node_modules/framework"]'

Note that the array items are interpreted as regular expressions.

UI doesn't load or doesn't work and refresh didn't help

Make sure that you have adblock disabled as well as any other content blocking scripts and plugins.

How can I (selectively) delete debug session metadata?

You may want to delete debug session metadata if for example Node Inspector gets in a bad state with some watch variables that were function calls (possibly into some special c-bindings). In such cases, even restarting the application/debug session may not fix the problem.

Node Inspector stores debug session metadata in the HTML5 local storage. You can inspect the contents of local storage and remove any items as needed. In Google Chrome, you can execute any of the following in the JavaScript console:

// Remove all
window.localStorage.clear()
// Or, to list keys so you can selectively remove them with removeItem()
window.localStorage
// Remove all the watch expressions
window.localStorage.removeItem('watchExpressions')
// Remove all the breakpoints
window.localStorage.removeItem('breakpoints')

When you are done cleaning up, hit refresh in the browser.

Node Inspector takes a long time to start up.

Try setting --no-preload to true. This option disables searching disk for *.js at startup. Code will still be loaded into Node Inspector at runtime, as modules are required.

How do I debug Mocha unit-tests?

You have to start _mocha as the debugged process and make sure the execution pauses on the first line. This way you have enough time to set your breakpoints before the tests are run.

$ node-debug _mocha

How do I debug Gulp tasks?

If you are running on a Unix system you can simply run the following command. The $(which ..) statement gets replaced with the full path to the gulp-cli.

$ node-debug $(which gulp) task

If you are running on Windows, you have to get the full path of gulp.js to make an equivalent command:

> node-debug %appdata%\npm\node_modules\gulp\bin\gulp.js task

You can omit the task part to run the default task.

Advanced Use

While running node-debug is a convenient way to start your debugging session, there may come time when you need to tweak the default setup.

There are three steps needed to get you up and debugging:

1. Start the Node Inspector server

$ node-inspector

You can leave the server running in background, it's possible to debug multiple processes using the same server instance.

2. Enable debug mode in your Node process

You can either start Node with a debug flag like:

$ node --debug your/node/program.js

or, to pause your script on the first line:

$ node --debug-brk your/short/node/script.js

Or you can enable debugging on a node that is already running by sending it a signal:

  1. Get the PID of the node process using your favorite method. pgrep or ps -ef are good

    $ pgrep -l node
    2345 node your/node/server.js
  2. Send it the USR1 signal

    $ kill -s USR1 2345
Windows

Windows does not support UNIX signals. To enable debugging, you can use an undocumented API function process._debugProcess(pid):

  1. Get the PID of the node process using your favorite method, e.g.

    > tasklist /FI "IMAGENAME eq node.exe"
    
    Image Name                     PID Session Name        Session#    Mem Usage
    ========================= ======== ================ =========== ============
    node.exe                      3084 Console                    1     11,964 K
  2. Call the API:

    > node -e "process._debugProcess(3084)"

3. Load the debugger UI

Open http://127.0.0.1:8080/?port=5858 in the Chrome browser.

Configuration

Both node-inspector and node-debug use rc module to manage configuration options.

Places for configuration:

  • command line arguments (parsed by yargs)
  • environment variables prefixed with node-inspector_
  • if you passed an option --config file then from that file
  • a local .node-inspectorrc or the first found looking in ./ ../ ../../ ../../../ etc.
  • $HOME/.node-inspectorrc
  • $HOME/.node-inspector/config
  • $HOME/.config/node-inspector
  • $HOME/.config/node-inspector/config
  • /etc/node-inspectorrc
  • /etc/node-inspector/config

All configuration sources that where found will be flattened into one object, so that sources earlier in this list override later ones.

Options

Option Alias Default Description
general
--help -h Display information about available options.
Use --help -l to display full usage info.
Use --help <option> to display quick help on option.
--version -v Display Node Inspector's version.
--debug-port -d 5858 Node/V8 debugger port.
(node --debug={port})
--web-host 0.0.0.0 Host to listen on for Node Inspector's web interface.
node-debug listens on 127.0.0.1 by default.
--web-port -p 8080 Port to listen on for Node Inspector's web interface.
node-debug
--debug-brk -b true Break on the first line.
(node --debug-brk)
--nodejs [] Pass NodeJS options to debugged process.
(node --option={value})
--script [] Pass options to debugged process.
(node app --option={value})
--cli -c false CLI mode, do not open browser.
node-inspector
--save-live-edit false Save live edit changes to disk (update the edited files).
--preload true Preload *.js files. You can disable this option
to speed up the startup.
--inject true Enable injection of debugger extensions into the debugged process. It's possible disable only part of injections using subkeys --no-inject.network. Allowed keys : network, profiles, console.
--hidden [] Array of files to hide from the UI,
breakpoints in these files will be ignored.
All paths are interpreted as regular expressions.
--stack-trace-limit 50 Number of stack frames to show on a breakpoint.
--ssl-key Path to file containing a valid SSL key.
--ssl-cert Path to file containing a valid SSL certificate.

Usage examples

Command line

Format
$ node-debug [general-options] [node-debug-options] [node-inspector-options] [script]
$ node-inspector [general-options] [node-inspector-options]
Usage

Display full usage info:

$ node-debug --help -l

Set debug port of debugging process to 5859:

$ node-debug -p 5859 app

Pass --web-host=127.0.0.2 to node-inspector. Start node-inspector to listen on 127.0.0.2:

$ node-debug --web-host 127.0.0.2 app

Pass --option=value to debugging process:

$ node-debug app --option value

Start node-inspector to listen on HTTPS:

$ node-debug --ssl-key ./ssl/key.pem --ssl-cert ./ssl/cert.pem app

Ignore breakpoints in files stored in node_modules folder or ending in .test.js:

$ node-debug --hidden node_modules/ --hidden \.test\.js$ app

Add --harmony flag to the node process running the debugged script:

$ node-debug --nodejs --harmony app

Disable preloading of .js files:

$ node-debug --no-preload app

RC Configuration

Use dashed option names in RC files. Sample config file (to be saved as .node-inspectorrc):

{
  "web-port": 8088,
  "web-host": "0.0.0.0",
  "debug-port": 5858,
  "save-live-edit": true,
  "preload": false,
  "hidden": ["\.test\.js$", "node_modules/"],
  "nodejs": ["--harmony"],
  "stack-trace-limit": 50,
  "ssl-key": "./ssl/key.pem",
  "ssl-cert": "./ssl/cert.pem"
}

Contributing Code

Making Node Inspector the best debugger for node.js cannot be achieved without the help of the community. The following resources should help you to get started.

Credits

Current maintainers

Alumni

  • Danny Coates - the original author and a sole maintainer for several years.
  • Miroslav Bajtoš - sponsored by StrongLoop, maintained Node Inspector through the Node.js 0.10 era.
  • 3y3 - maintained Node Inspector in 2015-2016

Contributors

Big thanks to the many contributors to the project, see Contributors on GitHub

node-inspector's People

Contributors

3y3 avatar ah01 avatar apla avatar auchenberg avatar bajtos avatar bluesmoon avatar bountysource-support avatar cattail avatar dannycoates avatar deteam avatar dininski avatar eplawless avatar focusaurus avatar gitter-badger avatar hustxiaoc avatar jakub-g avatar jimthedev avatar jldec avatar kreozot avatar marcelo-rocha avatar markc avatar mattheworiordan avatar michae1 avatar past avatar pritambaral avatar sam-github avatar schoonology avatar sethkrasnianski avatar sparkleholic avatar wendy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-inspector's Issues

stdout/stderr not forwarded

Is there some special magic to get the stdout/err forwarded to the web debugger like you do in your video and screenshots? I've tried to no avail, calling node-inspector --forward-io --profile and calling node --forward-io --profile server.js and calling node server.js --forward-io --profile etc etc - but nothing seems to work.

Can't start node-inspector

I get the following when trying to run node-inspector

diego@diego-Ubuntu:~/Node.js applications/Blog$
events.js:45
throw arguments[1]; // Unhandled 'error' event
^
Error: EADDRINUSE, Address already in use
at Server._doListen (net.js:1088:5)
at net.js:1059:14
at Object.lookup (dns.js:153:45)
at Server.listen (net.js:1053:20)
at Server.listen (/usr/local/lib/node/.npm/node-inspector/0.1.6/package/vendor/ws.js:108:22)
at Object.create (/usr/local/lib/node/.npm/node-inspector/0.1.6/package/lib/debug-server.js:44:12)
at /usr/local/lib/node/.npm/node-inspector/0.1.6/package/bin/inspector.js:52:11
at [object Object]. (fs.js:107:5)
at [object Object].emit (events.js:61:17)
at afterRead (fs.js:903:12)

clicked enable profiling while the debugged app was running without debug

node-inspector
visit http://127.0.0.1:8080/debug?port=5858 to start debugging

/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/session.js:119
    debug.request(
          ^
TypeError: Cannot call method 'request' of null
at evaluate (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/session.js:119:11)
at EventEmitter.<anonymous> (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/session.js:473:9)
at EventEmitter.<anonymous> (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/session.js:884:19)
at Connection.<anonymous> (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/debug-server.js:34:15)
at Connection.emit (events.js:27:15)
at [object Object].write (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/vendor/ws/connection.js:434:21)
at Stream.<anonymous> (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/vendor/ws/connection.js:79:16)
at Stream.emit (events.js:27:15)
at Stream._onReadable (net.js:757:14)
at IOWatcher.onReadable [as callback] (net.js:276:10)

npm install is busted

npm install -g node-inspector
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm ERR! couldn't read package.json in .
npm ERR! Error installing .
npm ERR! Error: ENOENT, No such file or directory 'package.json'
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to [email protected]
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm ERR! System Darwin 10.7.0
npm ERR! argv { remain: [],
npm ERR! argv cooked:
npm ERR! argv [ 'install',
npm ERR! argv '-g',
npm ERR! argv 'node-inspector' ],
npm ERR! argv original:
npm ERR! argv [ 'install',
npm ERR! argv '-g',
npm ERR! argv 'node-inspector' ] }
npm not ok

child processes

Hi!

Turned out I cannot debug child processes. I use multinode technique to span all CPU cores, so multiple node instances (children of master instance) are listening to the same socket which is created by master process (which is run under node-inspector) which itself doesn't listen to the socket. So the execution point never reaches where I can set breakpoints.

Any kludge for debugging such setups?

TIA,
--Vladimir

inspector 0.1.5 debug.request session.js:129 null ptr reference

When I try to connect node's debugger up to node-inspector I get this stack trace:

/home/nfeger/.node_libraries/.npm/node-inspector/0.1.5/package/lib/session.js:129
debug.request(
^
TypeError: Cannot call method 'request' of null
at evaluate (/home/nfeger/.node_libraries/.npm/node-inspector/0.1.5/package/lib/session.js:129:11)
at EventEmitter. (/home/nfeger/.node_libraries/.npm/node-inspector/0.1.5/package/lib/session.js:460:26)
at EventEmitter. (/home/nfeger/.node_libraries/.npm/node-inspector/0.1.5/package/lib/session.js:935:19)
at Connection. (/home/nfeger/.node_libraries/.npm/node-inspector/0.1.5/package/lib/debug-server.js:36:15)
at Connection.emit (events.js:27:15)
at [object Object].write (/home/nfeger/.node_libraries/.npm/node-inspector/0.1.5/package/vendor/ws/connection.js:434:21)
at Stream. (/home/nfeger/.node_libraries/.npm/node-inspector/0.1.5/package/vendor/ws/connection.js:79:16)
at Stream.emit (events.js:27:15)
at Stream._onReadable (net.js:757:14)
at IOWatcher.onReadable as callback

node version: 0.3.1-pre

"This webpage is not available" at host:8080

I'm trying to debug an application that's on a Rackspace cloud server and I only have SSH access. I can load host:8080/debug?port=5858 and I see my code and everything, but I can't break. Break buttons are grayed out.

When I go to host:8124 as per instructions , Chrome 11 shows "This webpage is not available".

Does this mean node-inspector can only debug locally?

"hide" js source files from the inspector

hi Danny,
is there a way to prevent some specific source files to be visible in the inspector?

If I have a file I want to debug, say hello.js, that in turns depends (via "require") on several "library" files, I would like to find a way so that the library files will be hidden by the user that is debugging.
This feature is very useful if you want to create a scripting environment and you want users to be able to run and debug their scripts in the environment without being able to see the "core" libraries..

Pause broken

Since node 0.3.1 nodejs/node-v0.x-archive@c7b24ef

Pausing with the pause button is likely to crash node-inspector since loop was moved out of javascript.

/usr/local/lib/node/.npm/node-inspector/0.1.0/package/lib/session.js:61
return bt.body.frames.map(function(frame) {
^
TypeError: Cannot call method 'map' of undefined
at callFrames (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/lib/session.js:61:29)
at /usr/local/lib/node/.npm/node-inspector/0.1.0/package/lib/session.js:116:60
at Object. (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/lib/callback.js:16:18)
at parse (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/lib/debugger.js:37:22)
at parse (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/lib/debugger.js:64:7)
at Stream. (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/lib/debugger.js:115:5)
at Stream.emit (events.js:27:15)
at Stream._onReadable (net.js:457:31)
at IOWatcher.onReadable as callback

cannot enable scripts

Your instructions on github go well for me, but when I open http://localhost:8080 in chrome (& chromium) It just says

"You need to enable debugging before you can use the Scripts panel"

So I click on the Enable Debugging icon in the bottom left, but nothing appears to happen..

Thanks!

Support 'Pause on next uncaught exception'

I saw in issue #16 that it apparently wasn't possible to 'Pause on uncaught' exceptions (because Node catches them). Tiem has passed, and if it has become possible it would be a great feature for newbies to Node like myself :-)

PS: Just close this issue if it doesn't make sense.

document "debugger;" keyword

...code...
debugger;
...code...

this stops the inspector, and is much more useful than --debug-brk switch in node !

Break on Exception

I haven't been able to find a way to break on exeception. Is this a feature or in the roadmap?

Some scripts cause parse error which crashes node-inspector

When using nodejs-yui3 and running the following script, node-inspector throws a parse error (see below the script).

var sys = require('sys'),
    YUI = require("yui3").YUI,
    http = require('http');

YUI({
    filter: 'debug',
    _logExclude: {
        'attribute': true,
        'base': true,
        'get': true,
        'loader': true,
        'yui': true,
        'widget': true,
        'event': true
    },
    debug: true
}).use('nodejs-dom', 'event', 'node', function(Y) {

    document = Y.Browser.document;
    navigator = Y.Browser.navigator;
    window = Y.Browser.window;
    

    var docType = '' + "\n";

    http.createServer(function (req, res) {
        YUI().use('nodejs-dom', 'event', 'node', function(Y) {
            var document = Y.Browser.document;
            document.title = 'This is a test';
            var i = Y.Node.create('Test This');
            i.addClass('foo');
            Y.one('body').append(i);

            var test = Y.Node.create('<script>document.getElementById("test").innerHTML = "test";</script>');
        Y.one('body').append(test);

        var div = document.createElement('div');
        div.id = 'foo';
        div.innerHTML = '<em id="foo">Test</em> this <strong id="bax">awesome!</strong>';
        document.body.appendChild(div);
        //document.body.appendChild('<script>alert("hello");</script>');
        

        
        var foo = Y.one('#foo');
        foo.addClass('bar');
        sys.puts(document.outerHTML);

        res.writeHead(200, {'Content-Type': 'text/html'});
        var out = docType + document.outerHTML; //Page.one('doc').get('outerHTML');
        res.write(out);
        res.close();

})}).listen(8000);

Y.log('Server running at http://127.0.0.1:8000/');

});

The error:

undefined:1
running":true}Co
              ^^
SyntaxError: Unexpected token ILLEGAL
    at Object.parse (native)
    at parse (/home/pflueger/lib/node/.npm/node-inspector/0.0.2-1-LINK-5ec80e92/package/lib/debugger.js:33:26)
    at Stream. (/home/pflueger/lib/node/.npm/node-inspector/0.0.2-1-LINK-5ec80e92/package/lib/debugger.js:89:5)
    at Stream.emit (events:26:26)
    at IOWatcher.callback (net:484:33)
    at node.js:769:9

I put a try/catch around the problem just see what was going on. This is what I got:

13 Sep 14:44:50 - Caught error { message: [Getter/Setter]
, stack: [Getter/Setter]
, type: 'unexpected_token'
, arguments: [ 'ILLEGAL' ]
} parsing: {"seq":0,"request_seq":862349515314,"type":"response","command":"scripts","success":true,"body":[{"handle":1,"type":"script","name":"/home/pflueger/lib/node/.npm/jsdom/0.1.9/package/lib/jsdom/browser/htmltodom.js","id":46,"lineOffset":0,"columnOffset":0,"lineCount":135,"source":"(function (exports, require, module, __filename, __dirname) { var HtmlToDom = function(parser){\n  \n  if(parser && parser.write) {\n    // sax parser\n    \n    this.appendHtmlToElement = function(html, element){\n\n      var currentElement = element, currentLevel = 0;\n\n      parser.onerror = function (e) {};\n\n      parser.ontext = function (t) {\n        var ownerDocument = currentElement.ownerDocument || currentElement;\n        var newText = ownerDocument.createTextNode(t);\n        currentElement.appendChild(newText);\n      };\n\n      parser.onopentag = function (node) {\n        var nodeName  = node.name.toLowerCase(),\n            document   = currentElement.ownerDocument || currentElement,\n            newElement = document.createElement(nodeName),\n            i          = 0,\n            length     = (node.attributes && node.attributes.length) ? \n                          node.attributes.length                     :\n                          0;\n        for (i in node.attributes)\n        {\n          if (node.attributes.hasOwnProperty(i)) {\n            newElement.setAttribute(i, node.attributes[i]);\n          }\n        }\n        currentElement.appendChild(newElement);\n        currentElement = newElement;\n      };\n\n      parser.onclosetag = function(node) {\n        currentElement = currentElement.parentNode;\n      }\n\n      parser.write(html).close();\n\n      return element;\n    }\n    \n  } else if(parser && (parser.ParseHtml || parser.DefaultHandler)) {\n    \n    // Forgiving HTML parser\n    \n    if(parser.ParseHtml){\n      // davglass/node-htmlparser\n    } else if(parser.DefaultHandler){\n      // tautologistics/node-htmlparser\n      parser.ParseHtml = function(rawHtml){\n        var handler = new this.DefaultHandler();\n        var parser = new this.Parser(handler);\n        parser.parseComplete(rawHtml);\n        return handler.dom;\n      }\n    }\n    \n    this.appendHtmlToElement = function(html, element){\n\n      if (typeof html !== 'string') {\n          html +='';\n      }\n      \n      var parsed = parser.ParseHtml(html);\n\n      for (var i = 0; i < parsed.length; i++) {\n          setChild.call(element, parsed[i]);\n      }\n\n      return element;\n      \n    }\n    \n  } else if(parser && parser.moduleName == 'HTML5') { /* HTML5 parser */\n    this.appendHtmlToElement = function(html, element) {\n      if(typeof html !== 'string') html += '';\n      var p = new parser.Parser({document: element.ownerDocument});\n      var tree = p.parse_fragment(html, element);\n      throw new Error(\"Fixme!\");\n    }\n  } else {\n    \n    this.appendHtmlToElement = function(){\n      var sys = require('sys');\n      sys.puts('');\n      sys.puts('###########################################################');\n      sys.puts('#  WARNING: node-htmlparser could not be found.');\n      sys.puts('#  Element.innerHTML setter support has been disabled');\n      sys.puts('#  Element.innerHTML getter support will still function');\n      sys.puts('#  Download: http://github.com/tautologistics/node-htmlparser');\n      sys.puts('###########################################################');\n      sys.puts('');\n\n    }\n\n  } \n}\n\n// utility function for forgiving parser\nvar setChild = function(node) {\n\n    var newNode, currentDocument = this._ownerDocument || this;\n    \n    if (node.type == 'tag' || node.type == 'script' || node.type == 'style') {\n        newNode = currentDocument.createElement(node.name);\n    }\n    if (node.type == 'text') {\n        newNode = currentDocument.createTextNode(node.data);\n    }\n    if (node.type == 'comment') {\n        newNode = currentDocument.createComment(node.data);\n    }\n    if (node.attribs && newNode) {\n        for (var c in node.attribs) {\n            newNode.setAttribute(c, node.attribs[c]);\n        }\n    }\n    if (node.children && newNode) {\n        for (var c = 0; c < node.children.length; c++) {\n            setChild.call(newNode, node.children[c]);\n        }\n    }\n    if (newNode) {\n        return this.appendChild(newNode);\n    } else {\n        return null;\n    }\n};\n\nexports.HtmlToDom = HtmlToDom;\n\n});","sourceLength":4054,"scriptType":2,"compilationType":0,"context":{"ref":0},"text":"/home/pflueger/lib/node/.npm/jsdom/0.1.9/package/lib/jsdom/browser/htmltodom.js (lines: 135)"},{"handle":3,"type":"script","name":"buffer","id":17,"lineOffset":0,"columnOffset":0,"lineCount":335,"source":"(function (exports, require, module, __filename, __dirname) { var SlowBuffer = process.binding('buffer').SlowBuffer;\n\n\nfunction toHex (n) {\n  if (n < 16) return \"0\" + n.toString(16);\n  return n.toString(16);\n}\n\n\nSlowBuffer.prototype.inspect = function () {\n  var out = [],\n      len = this.length;\n  for (var i = 0; i < len; i++) {\n    out[i] = toHex(this[i]);\n  }\n  return \"\";\n};\n\n\nSlowBuffer.prototype.toString = function (encoding, start, end) {\n  encoding = String(encoding || 'utf8').toLowerCase();\n  start = +start || 0;\n  if (typeof end == \"undefined\") end = this.length;\n\n  // Fastpath empty strings\n  if (+end == start) {\n    return '';\n  }\n\n  switch (encoding) {\n    case 'utf8':\n    case 'utf-8':\n      return this.utf8Slice(start, end);\n\n    case 'ascii':\n      return this.asciiSlice(start, end);\n\n    case 'binary':\n      return this.binarySlice(start, end);\n\n    case 'base64':\n      return this.base64Slice(start, end);\n\n    default:\n      throw new Error('Unknown encoding');\n  }\n};\n\n\nSlowBuffer.prototype.write = function (string, offset, encoding) {\n  // Support both (string, offset, encoding)\n  // and the legacy (string, encoding, offset)\n  if (!isFinite(offset)) {\n    var swap = encoding;\n    encoding = offset;\n    offset = swap;\n  }\n\n  offset = +offset || 0;\n  encoding = String(encoding || 'utf8').toLowerCase();\n\n  switch (encoding) {\n    case 'utf8':\n    case 'utf-8':\n      return this.utf8Write(string, offset);\n\n    case 'ascii':\n      return this.asciiWrite(string, offset);\n\n    case 'binary':\n      return this.binaryWrite(string, offset);\n\n    case 'base64':\n      return this.base64Write(string, offset);\n\n    default:\n      throw new Error('Unknown encoding');\n  }\n};\n\n\n// slice(start, end)\nSlowBuffer.prototype.slice = function (start, end) {\n  if (end > this.length) {\n    throw new Error(\"oob\");\n  }\n  if (start > end) {\n    throw new Error(\"oob\");\n  }\n\n  return new Buffer(this, end - start, +start);\n};\n\n\n// Buffer\n\nfunction Buffer (subject, encoding, offset) {\n  if (!(this instanceof Buffer)) {\n    return new Buffer(subject, encoding, offset);\n  }\n\n  var type;\n\n  // Are we slicing?\n  if (typeof offset === 'number') {\n    this.length = encoding;\n    this.parent = subject;\n    this.offset = offset;\n  } else {\n    // Find the length\n    switch (type = typeof subject) {\n      case 'number':\n        this.length = subject;\n        break;\n\n      case 'string':\n        this.length = Buffer.byteLength(subject, encoding);\n        break;\n\n      case 'object': // Assume object is an array\n        this.length = subject.length;\n        break;\n\n      default:\n        throw new Error(\"First argument need to be an number, array or string.\");\n    }\n\n    if (this.length > Buffer.poolSize) {\n      // Big buffer, just alloc one.\n      this.parent = new SlowBuffer(this.length);\n      this.offset = 0;\n\n    }TypeError: Cannot read property '1' of null
    at parse (/home/pflueger/lib/node/.npm/node-inspector/0.0.2-1-LINK-5ec80e92/package/lib/debugger.js:54:12)
    at parse (/home/pflueger/lib/node/.npm/node-inspector/0.0.2-1-LINK-5ec80e92/package/lib/debugger.js:41:9)
    at Stream. (/home/pflueger/lib/node/.npm/node-inspector/0.0.2-1-LINK-5ec80e92/package/lib/debugger.js:93:5)
    at Stream.emit (events:26:26)
    at IOWatcher.callback (net:484:33)
    at node.js:769:9

Crashes on start with node v 0.5.0-pre

Using node version v0.5.0-pre and node-inspector 0.1.6

$ node-inspector &

$ visit http://0.0.0.0:8989/debug?port=5858 to start debugging

$ node interface.js 
_linklist.js:65
  item._idleNext = list._idleNext;
                       ^
TypeError: Cannot read property '_idleNext' of undefined
    at Object.append (_linklist.js:65:24)
    at Object.active (timers.js:136:9)
    at Socket._onReadable (net_legacy.js:663:12)
    at IOWatcher.onReadable [as callback] (net_legacy.js:177:10)
^C[1]+  Exit 1                  node-inspector --web-port=8989

From a google search it looks to be something with the web-socket-server related to http://stackoverflow.com/questions/6341510/node-js-connection-error-missing-property

debugged process should not break when no ui is attached

Inspector should automatically continue the debugged process when a break event occurs and no gui is attached. This mimics the behavior of the client side debugger.

Or if breakpoints are saved by the gui with web sql, remove all breakpoints on disconnect and restore on reconnect.

Node Application Segfaults as soon as a breakpoint triggers

I'm running node-inspector, and the browser page opens fine.

Running the app via node --debug works as well, and the node-inspector page shows the files from the app and lets me insert a breakpoint. However, as soon as the application reaches a breakpoint, the application seg-faults and node-inspector disconnects.

Running the application via --debug-brk causes it to output "debugger listening on port 5858", but as soon as node-inspector tries to connect I get the segfault. What's happening?

Method to refresh the scripts list

When running with the --debug-brk option, scripts imported with require() don't show up in the scripts popup. Works fine with the --debug option.

Is there some way to get the scripts list to refresh after require()?

Show __proto__

proto not shown

node-inspector does not show __proto__ in the Scope Variables pane. In-browser Web Inspector does.

Refreshing page crash

Refreshing the inspector crashes node-inspector.

/usr/local/lib/node/.npm/node-inspector/0.1.0/package/vendor/ws/connection.js:190
client._req.socket.flush();
^
TypeError: Object # has no method 'flush'
at /usr/local/lib/node/.npm/node-inspector/0.1.0/package/vendor/ws/connection.js:190:22
at Connection.close (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/vendor/ws/connection.js:312:3)
at Connection. (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/vendor/ws/connection.js:123:20)
at Connection.emit (events.js:27:15)
at Connection.state (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/vendor/ws/connection.js:268:10)
at Stream. (/usr/local/lib/node/.npm/node-inspector/0.1.0/package/vendor/ws/connection.js:89:18)
at Stream.emit (events.js:27:15)
at Stream._onReadable (net.js:444:51)
at IOWatcher.onReadable as callback

Debugging Stops Working After Editing Source

Hi there,

As soon as I double-click on any source code (to edit it) the debugger stops working. That is to say, it will no longer stop at any break-points, etc.

I'm using Chrome 12.0.742.112; node-inspector 0.1.6; node 0.4.9; Ubuntu 11.04.

Please let me know how I can help to debug this problem!

Thanks,
Mike

Can't start node-inspector

When I try "node-inspector &", I have the answer : "bash: node-inspector: command not found"

(node-inspector had been installed with npm without errors).

Thanks for your help,
Philippe

Long and numerous file names

From Floby:

I'm currently debugging a somewhat heavy application using a lot of express and connect.
The problem is that the scripts list is long and won't scroll. Moreover, file names aren't displayed entirely and since they're in a deep hierarchy (connect and express installed via npm) I can't differenciate them.

I would suggest that file names are displayed entirely or a mangled version of it, that libraries installed in the .node_libraries be displayed at the end of the list or not at all and of course that the list DOES scroll =) but I'm sure that this last one is a minor bug.

Conditional Breakpoints

Hi Danny,

Will it be possible to support conditional breakpoints like in the Chrome web inspector (by creating a break-point, right clicking on it and editing it).

On a side note great work on this debugger, wasn't really a fan of the eclipse plugin

clicked many times step into very quickly between two debug points

visit http://127.0.0.1:8080/debug?port=5858 to start debugging

/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/session.js:369
                props = objProps.map(function(p) {
                                 ^
TypeError: Cannot call method 'map' of undefined
at /home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/session.js:369:38
at Object.<anonymous> (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/callback.js:16:18)
at parse (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/debugger.js:38:29)
at Stream.<anonymous> (/home/rakia/.node_libraries/.npm/node-inspector/0.1.4/package/lib/debugger.js:114:5)
at Stream.emit (events.js:27:15)
at Stream._onReadable (net.js:752:31)
at IOWatcher.onReadable [as callback] (net.js:276:10)

Connection refused, exited with code: 127

FWIW I am getting this following the first lot of instructions. Linux x86_64, node from git compiled with --debug using gcc 4.5.0.

~/nodejs/node-inspector sudo node bin/inspector.js --start=test/hello.js
visit http://127.0.0.1:8080 to start debugging
proc exited with code: 127 signal: null

events:12
    throw arguments[1];
                       ^
Error: ECONNREFUSED, Connection refused
    at IOWatcher.callback (net:871:22)
    at node.js:267:9

BUG: node-inspector crashes when reconnecting node v0.3.2-pre

hi dannycoates,

tried to re-connect to node after navigating away or closing the debugger tab and reconnecting results in the following crash message:

/usr/local/lib/node/.npm/node-inspector/0.1.4/package/lib/session.js:163
path: s.name.split('/')
^
TypeError: Cannot call method 'split' of undefined
at /usr/local/lib/node/.npm/node-inspector/0.1.4/package/lib/session.js:163:22
at Array.map (native)
at parsedScripts (/usr/local/lib/node/.npm/node-inspector/0.1.4/package/lib/session.js:156:28)
at /usr/local/lib/node/.npm/node-inspector/0.1.4/package/lib/session.js:245:13
at Object. (/usr/local/lib/node/.npm/node-inspector/0.1.4/package/lib/callback.js:16:18)
at parse (/usr/local/lib/node/.npm/node-inspector/0.1.4/package/lib/debugger.js:38:29)
at Stream. (/usr/local/lib/node/.npm/node-inspector/0.1.4/package/lib/debugger.js:114:5)
at Stream.emit (events.js:31:17)
at Stream._onReadable (net.js:563:31)
at IOWatcher.onReadable as callback
Error 0

break on line

Would be nice if we could have a line of code which says:

debugger.break();

Then node-inspector runs the code to this point and breaks.

I had a look around in the other issues looking for any mentions of this but couldn't find anything.

Thanks

Breaks when stepping into files `require()`d after load

If I start node with, say, --debug-brk, and step past some require()s at the top of the file in node-inspector, the newly-in-scope files aren’t loaded. Later, if I step into a function loaded from one of these requires, I lose the program counter and the debugger controls become disabled; there’s nothing more I can do.

Has anyone run into a workaround for this kind of situation? Some way to make node-inspector load more files?

Stepping into mongodb client collection

Hello,
I am trying to debug a problematic function in my node.js script which connects to mongodb using the node-mongodb-native driver, and gets a collection. If I put a breakpoint on the following line and step into, it stops executing:
client.collection('_pm_offers', function (err, collection_impressions) {

Any ideas??

Thank you,
Igor Ganapolsky

Does not get all files loaded shown in dropdown.

I a larger program I have, most of the time I do not get all the loaded files shown in the dropdown. I tried creating a minimal example, but haven't been able to do that yet. I create this issue to gauge if other experience this and I will follow up, when I (hopefully) get a minimal example working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.