Debugging Express apps
See every request your Express app handles, with the error it threw, its database queries, outgoing calls and logs, in a free dashboard on your machine.
npm install peekinsidePeekInside shows what your Express app does with each request: the request and the response, the error it threw with your lines of code around it, the database queries it ran, the APIs it called and what it logged, in a dashboard on your machine. It takes one line, and works with Express 4 and 5.
import express from 'express';
import PeekInside from 'peekinside';
const app = express();
PeekInside.attach(app);
app.use(express.json());
// ...your routes
app.listen(3000);
Start your app as usual. PeekInside prints the link to its dashboard:
[peekinside] Requests from orders-api: http://localhost:7335/p/orders-api-1a2b3c4d
Middleware order doesn't matter: request bodies are captured as your app reads them, after express.json() or before it. Apps made with http.createServer(app) are found by themselves, and so are routers made with express.Router().
What you see for each request#
- The request and the response: method, URL, headers, query, route parameters, bodies (JSON, forms, text; up to 64 KB each), status and duration.
- The error it threw, with its stack trace and your source lines around the frames of your own code (TypeScript through source maps), grouped with the same error from other requests.
- Its database queries: pg, mysql2, Prisma, MongoDB and Mongoose, and the ORMs built on them (Knex, Sequelize, TypeORM, Drizzle, Kysely), with slow queries and N+1 loops flagged.
- Its outgoing calls, through axios, got and the rest of
node:http, orfetch. - What it logged, with the console, pino or winston.
- A timeline of all of it, so you see which query or call took the time.
Express errors#
PeekInside records the errors Express routes: thrown by a handler, passed to next(err), or, with Express 5, rejected by an async handler. It tells apart the errors your app answers from the ones it doesn't:
- An error that reaches one of your error middleware,
(err, req, res, next), is recorded as handled. - An error that reaches Express's default handler, which answers 500, is unhandled.
Errors with a 4xx status, such as createError(404), are how apps answer bad requests, and aren't recorded. Crashes (uncaught exceptions and unhandled rejections) are recorded too, with the request they happened in. Nothing about how your app answers changes.
Routes, users and your own values#
- The Routes page lists every route with its traffic, error rate and response times, ids in paths folded together (
/orders/42and/orders/43are bothGET /orders/:id). - Call
PeekInside.setUser(req.user)in your authentication middleware, and every request and error says who it was for. PeekInside.dump(value)shows a value in the dashboard, under its request, as a tree you can open:console.logfor the objects you want to look at.
In production#
The local dashboard is for your machine: it's off when NODE_ENV is production. On your servers, the same line sends to PeekInside Cloud when PEEKINSIDE_API_KEY is set, encrypted before it leaves your server. Using Express inside NestJS? See NestJS.
Try it on your app
Install the package, add PeekInside.attach(app), and start your app as usual: it prints the link to its dashboard. Free, no account, and your data stays on your machine. On your servers, the same line reports to PeekInside Cloud once it has an API key.