Does GitHub retry failed webhooks? No, and what to do about it
There is a red entry in your Recent Deliveries tab, it is timestamped four hours ago, and what you actually want to know is whether GitHub already sent it again while you were asleep.
It did not. GitHub does not automatically redeliver a failed webhook delivery, for repository webhooks, organisation webhooks or GitHub App webhooks. One attempt, marked failed, and nothing further unless a person or a script asks for it. Whatever that event was going to cause in your system has not happened, and nothing is going to make it happen on its own.
GitHub's documentation says this outright, and said it when this page was written. The two numbers below, the response timeout and the window you have to recover in, are the sort of thing that changes quietly, so check them again before you build on them.
Why you expected a queue
The assumption is reasonable, because most senders do have one. Stripe attempts delivery for up to three days with an exponential back off and shows you when the next attempt is due. Against that shape, a red entry reads as "pending" rather than "gone".
It is an easy assumption to keep holding, and it tends to get written down: in a code comment, a runbook, a design note that says the retries will cover a gap. Search your own for it. Wherever it appears, something is relying on a safety net that is not there.
The three ways a delivery fails, and the clock you are racing
A non-2xx status, a response that takes longer than GitHub waits, or a connection that never completes. All three end identically, as one failed delivery with no successor.
The wait is ten seconds. Your server should respond with a 2xx inside that, and if it does not, GitHub terminates the connection and counts the delivery as a failure. That number has a consequence nobody mentions: any retry you add inside the handler is spending a budget that is already nearly gone, so it has to be measured in seconds.
If the handler calls something slow and occasionally overloaded, a model API for instance, keep that client's back off to a couple of seconds between attempts. The delivery is nearly out of time already, so nothing is gained by waiting politely, and one transient error that is not retried at all costs a whole response.
Redelivery exists, and it has an API
You can send it again yourself. In the interface: the webhook's settings, then Recent Deliveries, then the delivery GUID, then Redeliver.
Answers that tell you this is browser-only are out of date. There are REST endpoints for it, and they are the difference between a recovery you can script and one you cannot.
- Repository webhooks:
GET /repos/OWNER/REPO/hooks/HOOK_ID/deliveriesto list, andPOST /repos/OWNER/REPO/hooks/HOOK_ID/deliveries/DELIVERY_ID/attemptsto send one again. - App webhooks:
GET /app/hook/deliveriesandPOST /app/hook/deliveries/DELIVERY_ID/attempts. These want a JWT signed with the app's private key, not an installation token. - Organisation webhooks: the same pair, under the organisation's hooks.
The part that actually bites is the window. You can view and redeliver deliveries from the past three days. Not the past month, not since the incident started. Three days, after which the payload is gone and the only copy of what GitHub told you is whatever you kept.
Answer first, work afterwards, and what that costs
The shape most people will tell you to build is: verify the signature, put the payload somewhere durable, return 200, do the work outside the request. It is good advice, because it takes your slow work off GitHub's ten second clock entirely, leaving only a write you control inside the window.
Know what it trades away. Once you return 200 before the work, GitHub's record says the delivery succeeded whatever happens next, so your own queue becomes the only copy of the event, and it has to be at least as durable and as visible as the delivery log you gave up. The next section is about why that record matters.
A 200 on a failure destroys the only record you had
Because GitHub never retries, the status code stops being a retry instruction and becomes a filing decision. A failed delivery is not just a red mark. It is a durable, redeliverable copy of the event, sitting in GitHub's interface for three days, and a 200 erases it.
That is the same move as closing an issue because you could not reproduce it. A status is a claim about what you know, and using it to make something disappear from a queue does not settle what happened, it only stops anyone having to look.
Catch the exception, log it, return 200. GitHub records a successful delivery, the entry goes green, and in three days the payload is gone along with any way of replaying it.
Catch the exception, alert a human, return 500. The delivery stays red and redeliverable, and somebody knows within the minute that an issue went unanswered.
The cost is concrete for anything GitHub only tells you once. An installation event that arrives during a database blip and gets a 200 anyway leaves you with an installation you never recorded and no credential to act for it, and nothing will ever tell you.
Make every handler safe to run twice
Redelivery is your only recovery path, and a recovery path you are frightened to use is not one. So the handler has to be safe to run again. The tempting way to get there is to remember delivery identifiers and ignore ones you have seen.
Do not do that. When you request a redelivery, the X-GitHub-Delivery header is the
same as in the original delivery. A replay guard keyed on it will quietly swallow exactly the one
request you sent on purpose, which is the worst possible thing for it to swallow.
Deduplicate on the thing that happened instead. Key your records on what the event is about, such as the repository and issue number, and read before you create, so a second arrival for the same issue returns early rather than answering twice. Anything small you write on arrival, such as a filing record for burst detection, wants the same key for the same reason.
That gives you the honest version of the test. It is not "run it twice and the second run writes nothing", because a write to a deterministic key happens both times and lands on the same value. It is: run it twice and the second run produces no second side effect. No second comment, no second charge, no second notification. The distinction is the whole lesson.
Reconcile against the list, not against events that will not arrive
A webhook is a notification. It is not a source of truth, and treating it as one means your records are only ever as complete as your worst hour of uptime.
The list GitHub will answer on request is the truth. If a record of yours is built from more than one webhook, a lost one leaves it looking complete and unusable, with nothing surfacing it until a customer notices. A scheduled job that asks GitHub what is actually installed, and reruns the conclusion the missing webhook would have reached, repairs that within a day. Make every decision a function of the current records, so a second run straight after the first is safe.
The other half of the discipline is knowing what the job must refuse to do. It should not reactivate a cancelled subscription because the app happens to still be installed. Cancelling a plan and uninstalling an app are separate acts a customer can take in either order, and a job that quietly resells a plan on the strength of a leftover installation is a worse bug than the one it fixes. Report those pairs to a human and leave them alone.
Alert at the moment you drop one
You will not find a failed delivery later by browsing. Three days is not long enough for anyone to notice by accident, and a red entry among green ones is invisible unless something puts it in front of a person.
Post to wherever a person will see it the instant a handler throws, carrying the repository, the error, and the sentence that matters: GitHub does not retry, so this event got no response. Deduplicate the alert by a key, so a burst of identical failures posts once per window instead of once per issue. Failures that only go to logs are failures nobody reads.
Two more things belong here. Log the delivery identifier next to your own identifiers, so the entry in Recent Deliveries can be found again from your logs. And sweep the deliveries API periodically for failures, so twenty minutes of downtime does not become a permanent hole once the three days run out.
Whatever you build, name the cost in the user's terms rather than in yours. A dropped delivery is not an error rate. For anything conversational it is a person who wrote something and got no reply, which is the failure mode the product exists to prevent in the first place. It is also an item arriving in a queue nobody has agreed to look at, and it rots for the same reason things rot in an untriaged backlog: no owner, no agreed response, no deadline.
If one has already failed
- Read the response body and status GitHub recorded, not the one you expect. It is in the delivery.
- Decide whether the handler is healthy now. Redelivering into the same fault wastes one of the three days.
- Check the handler is idempotent before you send anything again, including that it is not deduplicating on the delivery identifier.
- Redeliver, from the interface for one, from the API for many.
- Confirm the side effect actually happened. The green tick means GitHub got a 200, not that your work succeeded.
- Work out how you would have found out if nobody had looked, and build that. It is the only step that prevents the next one.
WhatProblem asks these questions for you
It reads new GitHub issues and asks what is missing, in the issue thread, before anyone on your team has to.
Install from GitHub Marketplace