Node.js error tracking

Node.js error tracking with per-request context

@errorlenshq/node reports uncaught exceptions and unhandled promise rejections, isolates context per request in any HTTP server, and traces outgoing calls — with no dependencies.

Install and initialize

Node.js 18 or newer. Initialize before anything else in your entry file. ES modules and CommonJS both work.

npm install @errorlenshq/node
import * as ErrorLens from "@errorlenshq/node";

ErrorLens.init({
  dsn: process.env.ERRORLENS_DSN,
  tracesSampleRate: 0.2,
  enableLogs: true,
});

Automatic, for any Node.js server

  • Uncaught exceptions and unhandled rejections — reported, then the process exits exactly as Node.js would
  • Every incoming request gets its own scope (AsyncLocalStorage): users and breadcrumbs never mix between requests
  • Transactions named after the route, continuing incoming W3C traceparent headers
  • Outgoing http, https and fetch calls traced and propagated
  • Console output as breadcrumbs, source context for your own frames, secrets scrubbed
  • Express, Fastify, Koa and Hapi helpers for one-line error reporting

Serverless and scripts

// AWS Lambda, Google Cloud Functions…
export const handler = ErrorLens.wrapHandler(async (event) => {
  // events are sent before the function returns
});

// short scripts
await ErrorLens.flush();

Frequently asked questions

Will it change how my process crashes?

No. After reporting an uncaught error the SDK flushes and exits with code 1, as Node.js does by default, and it respects --unhandled-rejections=warn or none.

Does it support TypeScript?

Yes. Types are included, and the package ships both ES module and CommonJS builds.

How big is the SDK?

It has no third-party dependencies; the Node.js package and its core are about 35 KB packed.

Start tracking errors in minutes

Free hosted plan with 5,000 errors a month, or self-host with no limits. No credit card.