Node.js
Read CRONNUDGE_URL from the environment. Ping start, run the work, and ping fail with a short error string if it throws.
const url = process.env.CRONNUDGE_URL;
if (!url) throw new Error("CRONNUDGE_URL is not set");
await fetch(url + "/start", { method: "POST" });
try {
await run();
await fetch(url, { method: "POST" });
} catch (error) {
await fetch(url + "/fail", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ exit: 1, error: String(error).slice(0, 500) }),
});
throw error;
}- Bodies are truncated at 8 KB. Do not send secrets or full dumps.
- An Idempotency-Key header makes a retried ping a replay instead of a second event.
- Duration is the time from /start to the success ping.
Longer guide: EventBridge scheduled Lambda · BullMQ, node-cron, and Agenda · Cloud Scheduler and Cloud Run