Skip to content

Zero-dependency Express.js middleware preventing server crashes through automatic error handling. Features built-in observability dashboard, distributed tracing, Prometheus metrics, and 2.2x performance advantage over alternatives.

License

Notifications You must be signed in to change notification settings

sunnyghodeswar/crashless

Repository files navigation

Crashless Banner

โšก Crashless

Production-Ready Observability for Node.js
Zero npm-dependency middleware that prevents Express servers from crashing and provides built-in monitoring โ€” all from a single line of code.

npm version License: MIT Node.js Version


๐Ÿš€ Quick Start

npm install crashless
import express from 'express';
import crashless from 'crashless';

const app = express();
app.use(crashless()); // ๐ŸŽ‰ That's it!

app.get('/users/:id', async (req, res) => {
  const user = await db.getUser(req.params.id); // ๐Ÿ›ก๏ธ Errors safely caught
  res.json(user);
});

app.listen(3000);

๐Ÿ–ฅ๏ธ Dashboard: http://localhost:3000/_crashless


๐ŸŽฎ Try It Live

โ–ถ๏ธ One-Liner Setup
Simplest possible setup

โ–ถ๏ธ Full Featured Demo
All features enabled

โ–ถ๏ธ OpenTelemetry
OTel metrics & traces

โ–ถ๏ธ Prometheus Export
Prometheus-compatible metrics

โ–ถ๏ธ Custom Exporters
Sentry, Datadog integrations

โ–ถ๏ธ Production Dashboard
Secure production setup

Or clone locally:

git clone https://github.com/sunnyghodeswar/crashless-examples.git
cd crashless-examples && npm install

๐Ÿ“š Documentation

๐Ÿ“– Complete Docs
Full documentation site

๐Ÿš€ Getting Started
Installation & setup guide

โš™๏ธ Configuration
All configuration options

๐Ÿ“‹ API Reference
Complete API documentation

๐Ÿ’ก Examples
Common use cases & patterns

โšก Performance
Benchmarks & optimization


โœจ Key Features

๐Ÿ›ก๏ธ Automatic Error Handling

Catch all errors automaticallyโ€”sync, async, and promises. No try-catch needed.

app.use(crashless());

// Async errors - automatically caught
app.get('/data', async (req, res) => {
  const data = await fetchData(); // ๐Ÿ›ก๏ธ Safe
  res.json(data);
});

// Sync errors - also caught
app.get('/test', (req, res) => {
  throw new Error('Oops'); // ๐Ÿ›ก๏ธ Safe
});

๐Ÿ“Š Built-in Dashboard

Real-time observability dashboard with three powerful views:

  • System Dashboard - Request metrics, throughput, latency, route performance
  • Errors Dashboard - Error frequency, top failing routes, live error stream
  • Traces Dashboard - Request traces with waterfall visualization

Access: http://localhost:3000/_crashless

๐Ÿ” Distributed Tracing

Automatic tracing for HTTP requests, fetch() calls, and fs.readFile() operations.

app.use(crashless({
  telemetry: {
    traces: {
      enabled: true,
      samplingRate: 0.2 // Sample 20% of requests
    }
  }
}));

Export traces: GET /traces.json?format=otlp - OpenTelemetry OTLP format

๐Ÿ“ˆ OpenTelemetry Support

Full OpenTelemetry compatibility for metrics and traces.

app.use(crashless({
  telemetry: {
    engine: 'otel' // OpenTelemetry format
  }
}));

Endpoints:

  • GET /metrics/otel - OpenTelemetry metrics
  • GET /traces.json?format=otlp - OTLP trace export

๐Ÿ“Š Prometheus Metrics

Prometheus-compatible metrics export for Grafana integration.

app.use(crashless({
  telemetry: {
    engine: 'prometheus'
  }
}));

Endpoint: GET /metrics - Prometheus format

๐Ÿ”Œ Custom Exporters

Integrate with Sentry, Datadog, or any monitoring service.

app.use(crashless({
  exporters: [
    {
      name: 'sentry',
      onError: (error, metadata) => {
        Sentry.captureException(error, { extra: metadata });
      }
    },
    {
      name: 'datadog',
      onError: (error, metadata) => {
        datadogClient.sendError(error, metadata);
      }
    }
  ]
}));

โšก Zero Dependencies

Uses only Node.js built-ins. No external npm dependencies.

๐Ÿ” Production-Safe

  • Sensitive data masked automatically
  • IP whitelist & token authentication
  • Dashboard disabled in production by default
  • Configurable overhead (2-30%)

๐ŸŽฏ Use Cases & Examples

Minimal Setup (Error Handling Only)

app.use(crashless({
  telemetry: { engine: 'none' }
}));

Overhead: ~3% | Use case: High-traffic apps needing only error handling

Standard Production

app.use(crashless({
  telemetry: { engine: 'builtin' }
}));

Overhead: ~20% | Use case: Standard production with metrics

Production + Observability

app.use(crashless({
  telemetry: {
    engine: 'builtin',
    traces: { enabled: true, samplingRate: 0.2 }
  }
}));

Overhead: ~27% | Use case: Full observability with distributed tracing

OpenTelemetry Integration

app.use(crashless({
  telemetry: {
    engine: 'otel',
    traces: { enabled: true }
  }
}));

Use case: Integration with OTel collectors (Jaeger, Tempo, etc.)

Prometheus + Grafana

app.use(crashless({
  telemetry: {
    engine: 'prometheus'
  }
}));

Use case: Prometheus scraping for Grafana dashboards

Custom Monitoring Integration

app.use(crashless({
  exporters: [
    {
      name: 'sentry',
      onError: (error, metadata) => Sentry.captureException(error)
    }
  ]
}));

Use case: Integration with existing monitoring tools


๐ŸŽจ Dashboard Preview

System Overview

System Overview

Route Performance

Route Performance

Error Analytics

Error Analytics

Distributed Tracing (Waterfall View)

Distributed Tracing


๐Ÿ“Š Performance

Verified benchmarks (Node.js v24.3.0, M3 Pro, 50 concurrent users):

Configuration Throughput (req/s) Overhead
Plain Express 15,761 โ€”
Crashless (minimal) 15,406 +2.3%
Crashless (+metrics) 13,082 +20.5%
Crashless (+traces 20%) 12,390 +27.2%
express-async-errors 6,919 +127.8%

Key Insight: Crashless is ~2.2ร— faster than express-async-errors with full observability.

Run benchmarks yourself โ†’


โš–๏ธ Comparison

Feature Crashless express-async-errors APM Tools
Async error handling โœ… โœ… โš ๏ธ Config
Server crash prevention โœ… โš ๏ธ Partial โš ๏ธ External
Built-in dashboard โœ… โŒ โœ… Remote
OpenTelemetry support โœ… โŒ โœ…
Prometheus export โœ… โŒ โœ…
Custom exporters โœ… โŒ โš ๏ธ Limited
Distributed tracing โœ… โŒ โœ…
Zero dependencies โœ… โŒ โŒ
Local metrics โœ… โŒ โš ๏ธ Cloud
Free & open source โœ… โœ… โŒ
Avg overhead ~3-27% ~130% ~40-70%

๐Ÿ’ก Why Crashless?

The Problem

// โŒ WITHOUT CRASHLESS - Server crashes
app.get('/users/:id', async (req, res) => {
  const user = await db.getUser(req.params.id); // ๐Ÿ’ฅ Unhandled rejection = crash
  res.json(user);
});

The Solution

// โœ… WITH CRASHLESS - Server stays alive
app.use(crashless());

app.get('/users/:id', async (req, res) => {
  const user = await db.getUser(req.params.id); // ๐Ÿ›ก๏ธ Caught & logged
  res.json(user);
});

What You Get

  • ๐Ÿ›ก๏ธ Automatic error handling - Never crash from unhandled errors
  • ๐Ÿ“Š Built-in dashboard - Real-time metrics, errors, and traces
  • ๐Ÿ” Distributed tracing - See exactly what happens in every request
  • ๐Ÿ“ˆ OpenTelemetry - Full OTel compatibility
  • ๐Ÿ“Š Prometheus - Native Prometheus export
  • ๐Ÿ”Œ Custom exporters - Integrate with any monitoring tool
  • ๐Ÿ” Production-safe - Sensitive data masked automatically
  • โšก Zero npm dependencies - Uses only Node.js built-ins

๐Ÿ”— Links


๐Ÿ“„ License

MIT ยฉ Sunny Ghodeswar


Production-ready observability without the complexity.

Get Started โ€ข Documentation โ€ข Try Demo

About

Zero-dependency Express.js middleware preventing server crashes through automatic error handling. Features built-in observability dashboard, distributed tracing, Prometheus metrics, and 2.2x performance advantage over alternatives.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages