Monitor Node.js Cron Jobs
Learn how to monitor scheduled tasks in Node.js applications using the official Haspulse SDK or raw HTTP calls.
Features
- Official SDK with TypeScript support (npm install haspulse)
- Automatic start/success/fail with wrap() helper
- Works with node-cron, node-schedule, and setTimeout
- Zero-config retry and timeout handling
Code Examples
SDK with wrap()
import { HasPulse } from 'haspulse';
import cron from 'node-cron';
const haspulse = new HasPulse({
apiKey: process.env.HASPULSE_API_KEY
});
// wrap() automatically sends start/success/fail
cron.schedule('*/5 * * * *', async () => {
await haspulse.wrap('YOUR_CHECK_ID', async () => {
await processQueue();
});
});SDK manual ping
import { HasPulse } from 'haspulse';
const haspulse = new HasPulse({
apiKey: process.env.HASPULSE_API_KEY
});
// Manual control over lifecycle
await haspulse.ping('YOUR_CHECK_ID', { type: 'start' });
try {
await processQueue();
await haspulse.ping('YOUR_CHECK_ID'); // success
} catch (error) {
await haspulse.ping('YOUR_CHECK_ID', { type: 'fail' });
throw error;
}Raw HTTP (no SDK)
// No dependencies needed - just fetch
cron.schedule('*/5 * * * *', async () => {
await fetch('https://haspulse.io/ping/YOUR_CHECK_ID/start');
try {
await processQueue();
await fetch('https://haspulse.io/ping/YOUR_CHECK_ID');
} catch (error) {
await fetch('https://haspulse.io/ping/YOUR_CHECK_ID/fail');
throw error;
}
});How It Works
- 1Create a check in HaspulseSet your expected schedule (e.g., every 5 minutes)
- 2Add the ping to your codePing the unique URL when your job runs successfully
- 3Get alerted on failuresIf a ping doesn't arrive on time, we notify you
Related Integrations
Start monitoring in minutes
Create your first check and start receiving alerts when your scheduled jobs fail.
Get started free