How to Monitor Node.js Cron Jobs with CronRabbit

Node.js

The Problem

Node.js cron jobs using node-cron, bull, or setTimeout can fail silently due to unhandled promise rejections, memory leaks, or process crashes.

The Solution

Add a fetch() call to CronRabbit at the end of your job handler. If the ping doesn't arrive, you get an alert.

Why Node.js Jobs Fail Silently

Unhandled promise rejections, EventEmitter memory leaks, and uncaught exceptions can crash your process between runs. Since Node is single-threaded, one failure can bring down all scheduled jobs.

Integration with node-cron

Add a CronRabbit ping at the end of your cron.schedule callback. Use async/await with try/catch for proper error handling.

Code Examples

node-cron with monitoring

JavaScript
const cron = require("node-cron");

const PING = "https://ping.cronrabbit.com/your-id";

cron.schedule("0 2 * * *", async () => {
  await fetch(`${PING}/start`);
  try {
    await runDailyReport();
    await fetch(PING);
  } catch (err) {
    await fetch(`${PING}/fail`);
    console.error("Job failed:", err);
  }
});

BullMQ worker with monitoring

JavaScript
const { Worker } = require("bullmq");

new Worker("reports", async (job) => {
  const PING = "https://ping.cronrabbit.com/your-id";
  await fetch(`${PING}/start`);
  try {
    const result = await generateReport(job.data);
    await fetch(PING);
    return result;
  } catch (err) {
    await fetch(`${PING}/fail`);
    throw err;
  }
});

Ready to Monitor Your Cron Jobs?

Create your free account and add your first monitor in under 5 minutes. No credit card required.