MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / readCronJobsDataFromFile

Function readCronJobsDataFromFile

src/app/api/cron/route.ts:62–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62async function readCronJobsDataFromFile(): Promise<JsonRecord> {
63 let lastError: unknown;
64
65 for (let attempt = 0; attempt < CRON_JOBS_READ_ATTEMPTS; attempt += 1) {
66 try {
67 const content = await fs.promises.readFile(CRON_JOBS_PATH, "utf-8");
68 return JSON.parse(content) as JsonRecord;
69 } catch (error) {
70 lastError = error;
71
72 const retryableSyntaxError = error instanceof SyntaxError;
73 const retryableFsError = isErrnoException(error) && (error.code === "ENOENT" || error.code === "EBUSY");
74
75 if ((retryableSyntaxError || retryableFsError) && attempt < CRON_JOBS_READ_ATTEMPTS - 1) {
76 await delay(CRON_JOBS_RETRY_DELAY_MS * (attempt + 1));
77 continue;
78 }
79
80 throw error;
81 }
82 }
83
84 throw lastError instanceof Error ? lastError : new Error("Failed to read cron jobs");
85}
86
87async function readCronJobs(): Promise<JsonRecord[]> {
88 try {

Callers 1

readCronJobsFunction · 0.85

Calls 2

isErrnoExceptionFunction · 0.85
delayFunction · 0.70

Tested by

no test coverage detected