# How one bad timezone string could stop Rerun's scheduler

Say you set up a job to run every morning at 9 in your timezone, and you type the timezone as `Eastern`. The app saves it without a word. Later, quietly, the part of the app that runs all the scheduled jobs trips over that one word.

That was possible in Rerun, a self hostable app where you set up digital coworkers that use your tools and work on a schedule. I found it by reading the source, wrote it up as [issue #21](https://github.com/rerun-build/rerun/issues/21), and fixed it in [rerun-build/rerun#22](https://github.com/rerun-build/rerun/pull/22).

## Routines, cron and timezones

In Rerun, a coworker can have routines: saved jobs that repeat. Each one has a cron expression, a short code for a repeating time such as `0 9 * * *` for "every day at 9:00", and optionally a timezone.

Timezones have official names from a shared list called the IANA database, like `Europe/Paris` or `America/New_York`. A few short aliases work too, such as `UTC`, `EST` or `US/Eastern`. But `Eastern`, `Pacific Time` or a typo like `Europe/Pariss` aren't on that list.

A scheduler inside Rerun's engine wakes up every 30 seconds. Each time, called a tick, it looks at every routine of every active coworker and asks "is this one due yet?". If it is, it runs it.

## Where the bad value slipped through

Routines can be created in two ways: by the coworker itself, through tools called `schedule_create` and `schedule_update`, or through the app's web routes. Both checked the cron expression and the one off run time. Neither checked the timezone. Any text was accepted.

The second part is the library. Rerun uses croner, a JavaScript cron library, to work out the next run time. croner will build a schedule with any timezone text you give it, no questions asked. It only fails when you actually ask for a run:

```shell
> new Cron('0 9 * * *', { timezone: 'Eastern' }).nextRun()
TypeError: CronDate: Failed to convert date to timezone 'Eastern'. ...
```

I trimmed the end of that message, which goes on to suggest using an IANA name. So a bad timezone sailed through when it was saved and only blew up later, when someone needed the answer.

## What happened after that

Picture a teacher taking the register. She reads each name in order and ticks it off. If one name on the list is smudged and she can't read it, she stops right there, and everyone after it never gets marked present.

The scheduler's tick worked the same way. It asked croner about each routine in a plain loop with no `try` around it. When it hit the bad timezone, croner threw an error and the loop stopped. Every routine after that one, for that coworker and for every coworker after it, went unchecked on that tick.

It could get worse. The tick was started as `void tick()`, which means "run this, and don't wait for the result". So the error had nowhere to go. In Node, an async error nobody handles (an unhandled rejection) ends the whole process by default, and the engine had no handler of its own. I didn't run a full self hosted setup, so I want to be clear: the process exit follows from reading the code, not from a crash I watched. The croner error itself I did check, with the same croner version the repo uses, 10.0.1.

The coworker's own tools were hit too. `schedule_list` and `schedule_get` ask for each routine's next run, so they failed the same way. A cron expression that doesn't parse, say one typed into a routine file by hand, took the same path.

## The fix, part one: one bad routine can't stop the rest

First, the engine stopped assuming croner never throws. The two places that asked for a next run now go through one small helper:

```ts
function nextCronRun(schedule: Schedule, from: Date): Date | null {
    try {
        return cronFor(schedule).nextRun(from)
    } catch {
        return null
    }
}
```

If croner can't work out a run, the answer is `null`, meaning "no next run". A routine with no next run is never due, so the tick skips it and moves on to the next one. `schedule_list` shows "never" for it instead of failing. Rerun's web interface already handled it exactly this way: its own version of `nextRunAt` wraps croner in `try` and `catch`. Now the engine matches.

## The fix, part two: refuse it when it's saved

Second, a bad timezone gets turned away up front. I could have kept a list of valid timezone names, but lists drift out of date. Instead, the check asks croner itself:

```ts
export function isValidTimezone(timezone: string): boolean {
    try {
        new Cron('* * * * *', { timezone }).nextRun()
        return true
    } catch {
        return false
    }
}
```

It builds a throwaway schedule that runs every minute, asks for one run, and reports whether that worked. So it accepts exactly the timezones the scheduler will later be able to use, nothing more and nothing less.

The check sits right next to the existing cron and run time checks. The coworker tools now answer `Invalid timezone: Eastern. Use an IANA name, e.g. 'Europe/Paris' or 'America/New_York'.` and save nothing. Creating a routine through the web route gives a 400 error, the web's "bad request" answer, with `body: Invalid timezone`, and editing one gives a 400 with `invalid timezone`. Leaving the timezone empty still means "no timezone".

## Tests

Every new test fails on the main branch without the fix. The cron tests check which names `isValidTimezone` accepts and rejects, and that a routine with an unknown timezone or a broken cron is simply not due and has no next run, instead of throwing. The tool tests check that a refused create saves nothing and a refused update keeps the old timezone. The route tests check the two 400 answers.

There were no review comments. ClementJanssens merged it on 6 November 2026, then wrote a short summary on the issue of what the fix does and thanked me for the report and the fix. Thanks, ClementJanssens!

## What I'm keeping from this one

If a library checks its input late, check early using the library itself. Asking croner "can you run this?" stays correct as croner changes, and a hand written list wouldn't.

A loop that works through everyone's jobs shouldn't let one bad job stop the rest. Skip it, and keep going.

And when you report something you found by reading code, say so. Writing that the process exit follows from the code was honest. Writing "it crashed" would not have been.

Have you ever had a timezone name that looked fine and wasn't? I'd like to hear which one.

