MCPcopy
hub / github.com/firecrawl/firecrawl / processMonitorCheckJob

Function processMonitorCheckJob

apps/api/src/services/monitoring/runner.ts:941–1098  ·  view source on GitHub ↗
(
  job: MonitorCheckJobData,
)

Source from the content-addressed store, hash-verified

939}
940
941export async function processMonitorCheckJob(
942 job: MonitorCheckJobData,
943): Promise<void> {
944 const monitor = await getMonitorForUpdate(job.teamId, job.monitorId);
945 if (!monitor) {
946 throw new Error("Monitor not found");
947 }
948
949 const initialCheck = await getMonitorCheck(
950 job.teamId,
951 job.monitorId,
952 job.checkId,
953 );
954 if (!initialCheck) {
955 throw new Error("Monitor check not found");
956 }
957 if (TERMINAL_CHECK_STATUSES.has(initialCheck.status)) {
958 return;
959 }
960
961 await markMonitorRunning({
962 monitorId: monitor.id,
963 checkId: job.checkId,
964 });
965
966 let check: MonitorCheckRow = await updateMonitorCheck(job.checkId, {
967 status: "running",
968 started_at: new Date().toISOString(),
969 });
970
971 trackMonitorCheckStartedInterest({ monitor, check }).catch(error =>
972 logger.warn("Failed to track monitor target interest", {
973 error,
974 monitorId: monitor.id,
975 checkId: check.id,
976 eventType: "check_started",
977 }),
978 );
979
980 let lockId: string | null = null;
981 try {
982 const lock = await autumnService.lockCredits({
983 teamId: monitor.team_id,
984 value: check.estimated_credits ?? 1,
985 lockId: `monitor_${check.id}`,
986 expiresAt: Date.now() + 60 * 60 * 1000,
987 properties: {
988 source: "monitorCheck",
989 endpoint: "monitor",
990 jobId: check.id,
991 },
992 });
993
994 if (lock.status === "denied") {
995 check = await updateMonitorCheck(check.id, {
996 status: "skipped_no_credits",
997 finished_at: new Date().toISOString(),
998 actual_credits: 0,

Callers

nothing calls this directly

Calls 14

getMonitorForUpdateFunction · 0.90
getMonitorCheckFunction · 0.90
markMonitorRunningFunction · 0.90
updateMonitorCheckFunction · 0.90
StringFunction · 0.85
claimMonitorNotificationFunction · 0.85
sendNotificationsFunction · 0.85
lockCreditsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…