On 10 November 2026, during a GitHub incident, our runner control plane refused 17 CI jobs in 13 minutes. It logged no error, because from where it stood nothing had failed.
This is the second of five posts about running each GitHub Actions job on its own EC2 instance. The first post covers the design. This one is about the only input the system has, GitHub's workflow_job webhook, and what it takes to build on an input you cannot trust.
The version that fits on a napkin
The design looks like two event handlers:
- on
queued: launch an instance for the job; - on
completed: record the result.
It ran its first jobs on the first day. Then the event stream showed us three ways it was wrong.
A delivery arrives twice. GitHub can deliver the same event more than once. Two copies of one queued event, milliseconds apart, launched two instances. One ran the job. The other sat idle until something noticed.
An event arrives late. The webhook hands each event to a worker through an asynchronous queue, and that queue keeps no order. A queued event processed after its own completed put a finished job back in the waiting list, and we launched for a job that no longer existed.
An event never arrives. GitHub does not retry a delivery that failed. A job whose queued event was lost waited for a runner that nobody was going to start. GitHub lets a job wait like that for 24 hours before it gives up.
None of these is a bug in GitHub. It is what a webhook is. The napkin design assumed a log; what we had was a rumour.
Every write is conditional
The fix is one rule: a handler never assumes what came before it. Each job has one item in a DynamoDB table, and every write to it carries a condition.
A status only moves forward
A status write says, in its condition, "the item has no status yet, or its status is one that may move to this one". A late queued on a completed job fails that condition and changes nothing. An event that arrives first, with no item at all, creates one in whatever status it reports.
A write that loses its condition returns false. It does not throw. Losing is the normal case for a duplicate, and an exception there would send every duplicate to the dead-letter queue.
One launch per job
The launch is guarded by a claim, written in the same conditional update that records the job:
export const claimLaunch = (job: JobRef & {pool: PoolName}, now: string) => update(job.jobId, { set: {...queuedFields(job), launchClaimedAt: now}, condition: new dynamoose.Condition('launchClaimedAt') .not() .exists() .and() .parenthesis((c) => c.where('status').not().exists().or().where('status').eq('queued')) }); Two deliveries race for it and DynamoDB picks one. The loser stops before it calls GitHub or EC2. We tried the obvious alternative first, a check for an existing instance tagged with the job. Two workers can both look, both see nothing, and both launch. A read followed by a write is not a lock.
If the launch fails after the claim, the claim is released, so a retry can take it.
Count runners, do not match them
This is the rule that took us longest to accept. A just-in-time runner is registered with labels, not with a job. When it connects, GitHub gives it the oldest queued job those labels satisfy.
So the instance we launched for job A often runs job B. The tag on the instance says A. Nothing is wrong: two jobs were queued and two runners exist. But any code that asks "does job A have a runner?" by looking for A's instance gets the wrong answer.
The reaper, which runs every 5 minutes, therefore works by count. Per pool, it takes the jobs that have waited more than 3 minutes, subtracts the instances that are free or still booting, and launches the difference. It never asks which runner belongs to which job.
The same fact decides how a cancelled job is cleaned up. Its instance may have just taken another job. Checking whether the runner is busy and then terminating has a gap between the two calls. So we delete the runner first. GitHub refuses to delete a busy runner, and only when the delete succeeds is the instance safe to terminate.
The event that did arrive, and lied
Back to 10 November. Before it launches, the worker checks that the job's repository is in our runner group. We added that check on purpose: a repository outside the group can never get one of our runners, and its job would wait a day in silence. Rejecting it at once, with a metric, made a typo in a workflow file visible in a minute.
The list of repositories comes from GitHub's API, and we cached it for 5 minutes.
During the incident that endpoint answered 200 OK with a short list. Not an error, not a timeout: a valid response with some of the repositories missing. We cached it. For the next 13 minutes, every job from a missing repository was rejected, and a rejection is final by design, so those 17 jobs waited until a person re-ran them.
A guard written to make one failure loud had made a different failure silent.
The response carried its own evidence. It reports a total_count, and the items did not add up to it. We now refuse any list that does not:
if (pageItems.length < PER_PAGE) { if (opts.complete && items.length !== body.total_count) { throw new ServiceUnavailable('GitHub list incomplete', { path, listed: items.length, total: body.total_count }); } return items; } A short list is never cached. And before the worker rejects a job, it reads the list again, fresh. If that read fails, the worker throws, the event is retried, and the job is not rejected. The rule we took from it: a final decision needs better evidence than a cached one.
What it does not do
- No ordering. We never reconstruct the order of events. The conditions make order irrelevant for the state we keep, and we keep very little.
- No exactly-once. The claim stops duplicate deliveries, not every extra instance. When a job waits more than 3 minutes, because a boot was slow or GitHub was slow to assign it, the reaper may launch a second runner for it. We accept an idle instance over a lost job; it is removed after 15 minutes.
- A lost event still costs time. The reaper asks GitHub to redeliver failed deliveries every 5 minutes, and a second scheduled function lists, every 30 minutes, the queued jobs we have never heard of. A job whose event vanished starts minutes late. It does not start on time.
- Re-drives are capped at two per job. GitHub has reported jobs as queued after a runner took them, and without a cap each pass would launch another idle instance. A job that truly needs a third try waits for a person.
What we took from it
- Treat a webhook as a hint, not a log. Write handlers that are correct in any order and at any multiplicity, and add a slow loop that asks the source directly.
- A
200is not proof. When a response states its own size, check it. - Make final decisions on fresh evidence. Caches are for the path you can retry.



