V8 comes with a debugger that can be accessed from outside the process by using a TCP protocol. Node comes with a built-in client for the debugger, but we can also add external tools to connect to the debugger—such as node-inspector (https://www.npmjs.org/package/node-inspector).
To showcase the debugger, we will create a sample Express application that contains a bug (not that hard to spot actually). The application will have three endpoints:
/
: The main page will assign a random name and e-mail to the session in case they don't already exist, or redirect the user to/whoami
if they are already set/whoami
: This is used to check the name and e-mail stored in the session/refresh
: This destroys the session and redirects to the main page
The code for this application is as follows:
var express = require('express'); var app = express(); var morgan = require('morgan'); var cookieParser = require('cookie-parser'); var session = require('express...