Package Exports
- faultlens
- faultlens/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (faultlens) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
errorlens π
errorlens is a lightweight runtime error recorder, reproducer, and viewer for Node.js.
It captures errors where they actually happen, stores them (file system or MongoDB), lets you replay them, and provides an embedded web UI β all without SaaS, agents, or vendor lock-in.
Debug production issues locally.
One library. One server. Full visibility.
β¨ Features
- π§ͺ Capture runtime errors (sync, async, crashes)
- πΎ Store errors in file system or MongoDB
- π Replay captured errors via CLI
- π Embedded web viewer UI (same Express app)
- π Automatic sanitization of secrets
- π§© Pluggable storage architecture
- β‘ No external services required
π¦ Installation
npm install errorlensπ Quick Start (Express)
const express = require('express');
const {
init,
reproMiddleware,
attachViewer
} = require('errorlens');
const app = express();
app.use(express.json());
(async () => {
await init({
service: 'user-service',
storage: {
type: 'file',
dir: '.repro'
}
});
})();
app.get('/boom', (req, res, next) => {
next(new Error('π₯ Something went wrong'));
});
// Error middleware MUST be last
app.use(reproMiddleware());
// Attach viewer to the SAME server
attachViewer(app);
app.listen(3000, () => {
console.log('App running at http://localhost:3000');
console.log('Viewer available at http://localhost:3000/__repro');
});Trigger an error:
curl http://localhost:3000/boomπ Web Viewer
Open in browser:
http://localhost:3000/__reproThe viewer shows:
- Error name & message
- Full stack trace (collapsible)
- Service name
- Timestamp
- HTTP method & route
- Request payload (sanitized)
- Environment details
β Same server β No extra ports β Production-friendly
πΎ Storage Options
π File Storage (Default)
await init({
storage: {
type: 'file',
dir: '.repro'
}
});Each error is stored as a JSON snapshot on disk.
π MongoDB Storage (Optional)
await init({
storage: {
type: 'mongodb',
url: 'mongodb://localhost:27017',
db: 'errorlens',
collection: 'errors'
}
});Recommended for:
- Containers & Kubernetes
- Multiple app instances
- Centralized error storage
π Replay Errors
Copy the bugId from the viewer or storage and run:
npx errorlens replay <bugId>This prints the full captured snapshot so you can:
- Reconstruct the request
- Replay logic locally
- Debug deterministically
π‘οΈ Capture Fatal Crashes (Recommended)
To capture errors that would normally crash the process:
const { recordError } = require('errorlens');
process.on('uncaughtException', recordError);
process.on('unhandledRejection', recordError);This ensures errors are recorded even if the app exits.
π Security & Safety
- Sensitive fields are automatically redacted
- Disabled unless explicitly initialized
- No outbound network calls
- No SaaS or telemetry
- Safe to run in production
β οΈ Current Limitations (V1)
- HTTP replay is manual
- Express support first (Fastify planned)
- No distributed tracing (yet)
πΊοΈ Roadmap
- π Search & filters in UI
- π Viewer authentication
- π Click-to-replay HTTP requests
- π¦ Fastify & NestJS adapters
- π Metrics & trends
- π§ͺ Test utilities
π€ Contributing
Issues and PRs are welcome. If errorlens saves you debugging time, β the repo.
π License
MIT Β© Zubair