π₯ zero-crash
π‘οΈ Prevent silent crashes in Node.js apps in one line.
Global runtime crash protection for modern Node.js apps. Stop silent crashes, messy stack traces, and undefined exits.
zero-crash enforces disciplined failures, clean shutdowns, and human-readable crash logs β automatically.
Built for 2026 projects, production-safe, and dependency-free.
Most Node apps crash in ugly ways:
- Silent exits
- Infinite restart loops
- Unhandled promise rejections
- Random
process.exit(1) - No context, no discipline
zero-crash gives your app a runtime safety contract.
β Zero dependencies β Global crash interception β Clean exit codes β Shutdown hooks β Context-aware crash logs β Works for APIs, CLIs, bots, servers
npm install zero-crashconst zero = require("zero-crash");
zero.protect(async () => {
// your app logic
startServer();
});Thatβs it. Global crash protection is now active.
zero.role("api");Crash output will include role:
π₯ [api] RUNTIME_ERROR
zero.requireEnv(["PORT", "DB_URL"]);
zero.protect(async () => {
startServer();
});If missing:
π₯ [app] CONFIG_ERROR
Missing env: DB_URL
Exit: 2
zero.onShutdown(async () => {
await db.close();
await redis.quit();
});Runs on:
- crash
- Ctrl+C
- SIGTERM
- process exit
throw zero.config("Invalid configuration");
throw zero.dependency("MongoDB not reachable");Mapped exit codes:
| Type | Exit Code |
|---|---|
| Success | 0 |
| Runtime Error | 1 |
| Config Error | 2 |
| Dependency Error | 3 |
| Manual Interrupt | 130 |
const zero = require("zero-crash");
zero.role("bot");
zero.requireEnv(["SESSION"]);
zero.onShutdown(async () => {
console.log("Cleaning up...");
});
zero.protect(async () => {
throw zero.config("SESSION missing");
});π₯ [bot] CONFIG_ERROR
Reason: SESSION missing
Exit: 2
CrashID: ZC-A91F2B
Node: v20.11.1
Memory: 42MB
Uptime: 12s
zero.protect(app, {
verbose: false,
quiet: false,
json: false,
onCrash: (err, meta) => {
// send to webhook / logs
}
});| Option | Description |
|---|---|
verbose |
Show full stack trace |
quiet |
Disable console logs |
json |
Output crash info as JSON |
onCrash |
Custom crash hook |
- REST APIs
- CLI tools
- WhatsApp / Telegram bots
- Cron jobs
- Microservices
- Workers & daemons
If it runs on Node.js, zero-crash belongs there.
If this package improved your appβs stability:
π Give it a β on GitHub Stars help this project reach more developers β€οΈ
Want to improve zero-crash?
- π Found a bug? β Open an Issue
- β¨ Feature idea? β Create an Issue
- π§ Fix something? β Fork & Pull Request
- π Improvements welcome
Please contribute only through the official repository.
MIT License Β© 2026 Abhishek Suresh https://github.com/AbhishekSuresh2
β οΈ Please do not copy, rebrand, or republish this package as your own without explicit permission.
Failures are inevitable. Chaos is optional.
zero-crash makes crashes predictable, readable, and safe β so your app never dies silently again π₯π‘οΈ