-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
9.40.0
Framework Version
Next 15.4.3
Link to Sentry event
https://gabriel-lopes-organization.sentry.io/issues/alerts/rules/crons/flutter/sync-orders/details/
Reproduction Example/SDK Setup
The following Vercel Cron route src/app/api/cron/route.ts
does not flush Crons check-ins, causing them to be marked as "missed".
import { NextRequest, NextResponse } from "next/server";
import * as Sentry from "@sentry/nextjs";
export const GET = async (req: NextRequest) => {
const monitorSlug = "sync-orders";
const checkInId = Sentry.captureCheckIn(
{
monitorSlug,
status: "in_progress",
},
{
schedule: {
type: "crontab",
value: "* * * * *",
},
checkinMargin: 1,
maxRuntime: 15,
}
);
try {
Sentry.captureCheckIn({
checkInId,
monitorSlug: monitorSlug,
status: "ok",
});
} catch (e) {
Sentry.captureException(e);
Sentry.captureCheckIn({
checkInId,
monitorSlug: monitorSlug,
status: "error",
});
throw e;
}
return new NextResponse("OK", {
status: 200,
});
};
export const dynamic = "force-dynamic";
export const runtime = "nodejs";
export const maxDuration = 300;
Vercel.json:
{
"crons": [
{
"path": "/api/cron",
"schedule": "* * * * *"
}
]
}
Adding a await Sentry.flush()
before returning the response does the trick.
Steps to Reproduce
- Create a new Vercel cron route
- Instrument Crons
- Set up the Vercel cron job
Expected Result
The check-ins would be sent to Sentry and the monitor would have it's status as OK.
Actual Result
Check-ins are never sent and the monitor is in a failing state with missed check-ins.
Metadata
Metadata
Assignees
Type
Projects
Status
No status