Our daily job never ran. The schedule was in a config file the site never reads.

2026-12-04来源 dev.toEnglish

Our shop's assistant has a daily mission. Every morning it wakes up, answers ten questions, makes one decision, does the work, and logs what it did. That is the whole job — an agent that runs on a schedule so the owner doesn't have to poke it.

On the morning of December 3, it didn't run. Not an error, not a crash. Nothing. No output rows, no audit log, no sign it had ever been scheduled. The mission's last recorded action was from September.

The schedule was in the wrong file

The schedule exists. It says the job runs at 10:00 UTC every day. It is written in the project's netlify.toml.

The problem is that the shop's site doesn't read that file. The site's base directory is a subfolder, and that subfolder has its own netlify.toml — which contains no schedule blocks at all. So the schedule was declared, reviewed, and deployed, in a config file the live site never opens.

We proved it from the live side, not from the code. The hosting API lists every deployed function on the site — 126 of them. The scheduler is there, with its schedule field set to null. So is the background runner it would call. In fact, not one function on the entire site has a non-null schedule. The cron was never registered. The environment variables the scheduler needs are all present, so that wasn't it. The cron expression is correct. The handler code is intact. The schedule simply lived in a file the site doesn't read.

The one scheduled function that does work on the site proved the fix pattern. It declares its schedule in code, at the bottom of its own file — one line, next to the handler it belongs to. It doesn't depend on any config file at all.

So the fix was one line, in the same form, plus a header comment explaining the trap so nobody re-introduces it:

exports.config = { schedule: "0 10 * * *" }; 

Eighteen control tests passed, the file was pushed in a single commit, and the deploy went green. The new code is live.

The API still says null — and so does the working one

Here is the part we did not expect. After the deploy, we re-read the live function list. The scheduler still shows schedule: null.

Before concluding the fix had failed, we checked the precedent — the one function that definitely works, the one whose in-code schedule we copied. It also shows schedule: null.

So either that API field doesn't reflect in-code schedules at all, or in-code schedules genuinely don't register on this site — and the API cannot tell us which. The verification method was broken, not necessarily the fix. The only proof that counts is whether the job actually fires.

The owner didn't want to wait for tomorrow's scheduled run to find out. "It fires today. Not waiting til tomorrow." So we triggered it by hand at 11:35 AM.

It fired — and then it "stalled"

The manual trigger came back clean: one mission triggered, zero failed, in 754 milliseconds. The mission is "grow Krafted by nae." Twenty-six seconds later, the database had the proof: three new content rows — three TikTok and Reels video concepts — and one audit row recording the step. The job had run.

Then, forty minutes later, the mission still showed as "active." One step had succeeded and nothing had happened since. Our first read was that it had stalled after one step.

It hadn't. The investigation found no stall and no fix was needed. One invocation runs exactly one cycle — that is the design. Each cycle answers ten questions, makes one decision, executes, and logs. And a mission never completes itself: the only status change the runner makes is to "blocked." "Completed" is set only when a human stops the mission from the dashboard. Staying "active" after a successful cycle is correct behavior, not a failure. We had misread our own design.

Two things that did get proven by the manual run: the runner made two successful model calls with zero errors of the kind that broke it the day before — the temperature bug from our last post never appeared — and the scheduler, triggered by hand, does exactly what it's supposed to do.

What is not done yet

The in-code schedule is live, but whether it fires on its own is still unproven. The first real test is tomorrow morning's 10:00 UTC run, and a check is already scheduled for 4:30 AM to look for the invocation and the database rows. If it fires, the fix works despite the null API field. If it doesn't, the fallback is to put the schedule block in the subfolder's config — the file the site actually reads.

The same trap affects eleven other schedules that live only in the root config file. They are not fixed here; each one is a separate decision, and this fix was deliberately scoped to the one job that matters most.

The same morning, a second deploy shipped the spend watchdog that records every model call and enforces a hard stop — the guardrail that makes an always-on agent safe to leave running. That's a story of its own.

And the lesson from this one: a schedule is only real if it lives where the system that fires it actually looks. Ours was written down, reviewed, and deployed — in a file nobody reads. The job didn't fail. It was never asked to start.

原文:https://www.a8q9.cn/en/article/our-daily-job-never-ran-the-schedule-was-in-a-config-file-the-site-never-reads-899f71.html

相关文章