Update redeliver-failed-deliveries.js

This commit is contained in:
garfield69 2024-01-25 17:10:57 +13:00 committed by GitHub
parent 540dbb012a
commit 05889ad7e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -1,6 +1,9 @@
// This script uses GitHub's Octokit SDK to make API requests. For more information, see "[AUTOTITLE](/rest/guides/scripting-with-the-rest-api-and-javascript)."
const { App, Octokit } = require("octokit");
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
const secondDelivery = true;
//
async function checkAndRedeliverWebhooks() {
// Get the values of environment variables that were set by the GitHub Actions workflow.
@ -69,6 +72,13 @@ async function checkAndRedeliverWebhooks() {
// Redeliver any failed deliveries.
for (const deliveryId of failedDeliveryIDs) {
await redeliverWebhook({deliveryId, app});
// its likely ProBot was asleep when the first redeliver was sent and we know PRoBot startup takes about 12s
// so the first redeliver will likely timeout after 10s, but will have started ProBot
if (secondDelivery) {
secondDelivery = false;
// so we wait 13s so that the rest of the redeliveries will succeed
await sleep(13000);
}
}
// Update the configuration variable (or create the variable if it doesn't already exist) to store the time that this script started.